Question: In app during some transitions between screens (from app mode with veritical lock to game mode with horizontal lock ) I use

```
await SystemChrome.setPreferredOrientations([
  DeviceOrientation.landscapeRight,
  DeviceOrientation.landscapeLeft,
]);

```

to switch users between screen orientations, but sometimes this animation looks laggy on low-to-mid-end devices

**Is it possible in flutter to skip or for example speed up screen rotation animation?**

Or maybe someone know workaround without using setPreferredOrientations

Answer: 
You need to build your own arrayformula as follows

```
=arrayformulaJson(A2:A7,B1:D1)

```

code.gs

```
function arrayformulaJson(ids,xpath) {
  listIds = Array.isArray(ids) ? ids.flat() : [ids]
  listXpath = Array.isArray(xpath) ? xpath.flat() : [xpath]
  var result = []
  listIds.forEach(id => {
    var prov = []
    var json = JSON.parse(UrlFetchApp.fetch('https://api-apollo.pegaxy.io/v1/pegas/' + id).getContentText())
    listXpath.forEach(xp => {
      prov.push(json[xp])
    })
    result.push(prov)
  })
  return result
};

```

[![enter image description here](https://i.stack.imgur.com/lXQjc.png)](https://i.stack.imgur.com/lXQjc.png)

edit:
-----

to import the whole JSON including headers

```
=arrayformulaAllJson(A2:A7)

```

note that the result includes the headers, you may put the formula one row before the range

```
function arrayformulaAllJson(ids) {
  var listIds = Array.isArray(ids) ? ids.flat() : [ids]
  var listXpath = []
  var result = []
  listIds.forEach((id, i) => {
    var prov = []
    var json = JSON.parse(UrlFetchApp.fetch('https://api-apollo.pegaxy.io/v1/pegas/' + id).getContentText())
    if (i == 0) { 
      listXpath = Object.keys(json); 
      result.push(listXpath)
    }
    listXpath.forEach(xp => {
      prov.push(json[xp])
    })
    result.push(prov)
  })
  return result
}

```

[![enter image description here](https://i.stack.imgur.com/zZTXH.png)](https://i.stack.imgur.com/zZTXH.png)
You can support arrays on any custom function using [Array.map](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map):

```
/**
 * Adapts importjson to support arrays
 * Restriction: A url should only return one value
 *
 * @customfunction
 */
const importjsonArray = (urls, ...args) =>
  Array.isArray(urls)
    ? urls.map((url) => importjsonArray(url, ...args))
    : String(ImportJSON(urls, ...args));

```

### Usage:

```
=ARRAYFORMULA(IMPORTJSONARRAY("https://api-apollo.pegaxy.io/v1/pegas/"&A2:A3,"/energy","noHeaders"))

```

### Input:

|  | A |
| --- | --- |
| **A2** | 923195 |
| **A3** | 964911 |

### Output:

|  | A | B2:"=ARRAYFORMULA(IMPORTJSONARRAY("https://api-apollo.pegaxy.io/v1/pegas/"&A2:A3,"/energy","noHeaders")) |
| --- | --- | --- |
| **A2** | 923195 | 25 |
| **A3** | 964911 | 4 |