title: Flutter showing The method '[]' was called on null. on Listbuilder
body: <p>I am fetching data from an api and showing in ListView builder But its showing error</p>
  <pre><code> class MyHomePage extends StatefulWidget {
    MyHomePage({Key key, this.title}) : super(key: key);
  
  
    final String title;
  
    @override
    _MyHomePageState createState() =&gt; _MyHomePageState();
  }
  
  class _MyHomePageState extends State&lt;MyHomePage&gt; {
    int _counter = 0;
    bool show = false;
    var map = {};
    @override
    void initState() {
      dosomestuff();
  
    }
    Future&lt;List&gt; dosomestuff() async {
      http.Response res = await http.get(
        'http://retailapi.airtechsolutions.pk/api/menu/2112',
      );
  
      Map&lt;String, dynamic&gt; map = json.decode(res.body);
  
      if (map['description'] == &quot;Success&quot;) {
        print('show kr ');
        print(map[&quot;Categories&quot;].length);
        print(map[&quot;Categories&quot;]);
        setState(() {
          show = true;
        });
      }
    }
  
  
  
    @override
    Widget build(BuildContext context) {
  
      return Scaffold(
        appBar: AppBar(
  
          title: Text(widget.title),
        ),
        body: show
            ? ListView.builder(
          itemCount: map[&quot;Categories&quot;].length,
          scrollDirection: Axis.horizontal,
          shrinkWrap: true,
          physics: BouncingScrollPhysics(),
          itemBuilder: (context, index) {
            return Container(
              width: 80.0,
              child: Text(map[&quot;Categories&quot;][index]['Name'])
            );
          },
        ) : Container(),
  
      );
    }
  }
  </code></pre>
  <p>Its showing error <code>The method '[]' was called on null</code>. But when i print the values in state function the its priting values and all things are working but when ill show in ListBuilder then its showing that error.</p>
  <p>You can see i print the values in function</p>
  <pre><code>  print(map[&quot;Categories&quot;].length);
    print(map[&quot;Categories&quot;]);
  </code></pre>
  <p>And its printing values all things fine.</p>
  <p><a href="https://i.stack.imgur.com/YV3hz.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/YV3hz.png" alt="enter image description here" /></a></p>
  <p>You can see in image its printing the length and arrays fine so its not null when i use in widget its saying length is called on null -_-</p>