title: flutter initstate() list is not accessing another class widget
body: <p>I am creating an app with flutter. I want to fetch data from firebase and and shows grid view. The data is fetching correctly from firebase. The data fetching in <code>initState()</code> But it is not updating the another class <code>TheGridview</code> extends from <code>_MyHomePageState</code>. I am using a variable
   <code>documents</code> for storing list from firebase. <code>initState()</code> documents value but in the method <code>createchildwidget</code> the document became null. I tried so many methods please help me. The code is shown below.</p>
  
  <pre><code>    import 'dart:async';
      import 'package:flutter/material.dart';
      import 'package:augr/location/LocationScreen.dart';
      import 'package:cloud_firestore/cloud_firestore.dart';
  
      void main() =&gt; runApp(MyApp());
  
      class MyApp extends StatelessWidget {
        // This widget is the root of your application.
  
        MyApp({this.firestore});
        final Firestore firestore;
  
  
        @override
        Widget build(BuildContext context) {
          return MaterialApp(
              home: MyHomePage(title: 'My Shop', firestore: firestore)
          );
        }
      }
  
      class MyHomePage extends StatefulWidget {
  
        MyHomePage({Key key, this.title, this.firestore}) : super(key: key);
        final Firestore firestore;
        final String title;
  
        @override
        _MyHomePageState createState() =&gt; new _MyHomePageState(firestore: firestore);
      }
  
      class _MyHomePageState extends State&lt;MyHomePage&gt; {
        _MyHomePageState({this.firestore});
        final Firestore firestore;
        var documents = [];
  
        void initState(){
          Firestore.instance.collection("messages").getDocuments().then((data) async{
            var list = data.documents;
            documents = list;
            print("init state document:"+documents.length.toString());  // value is getting
            super.initState();
            setState((){
              documents = list;
            });
          });
  
  
  
        }
  
        @override
        Widget build(BuildContext context) {
          return new Scaffold(
            appBar: new AppBar(
              iconTheme: IconThemeData(
                color: Colors.black, //change font color here
              ),
              backgroundColor: new Color(0xFFFAFAFA),
            )
            title:"title",
            body: TheGridview().build(),
          );
        }
      }
  
      class TheGridview extends _MyHomePageState{
        Card makeGridCell(String name, IconData icon){
          return Card(
            elevation: 1.0,
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.stretch,
              mainAxisSize: MainAxisSize.min,
              verticalDirection: VerticalDirection.down,
              children: &lt;Widget&gt;[
                Center(child: Icon(icon)),
                Text(name)
              ],
            ),
          );
        }
  
        @override
        Widget build(BuildContext context) {
          return GridView.count(
            primary: true,
            padding: EdgeInsets.all(1.0),
            crossAxisCount: 2,
            childAspectRatio: 1.0,
            mainAxisSpacing: 1.0,
            crossAxisSpacing: 1.0,
  
            children: createchildwidget(),
  
            /*  children: &lt;Widget&gt;[
              makeGridCell("Home", Icons.access_alarm)
            ],*/
  
  
          );
        }
  
        List&lt;Widget&gt; createchildwidget(){
          print("createchildwidget:"+documents.length.toString()); // the value getting 0
          List&lt;Widget&gt; createchildwidget = List&lt;Widget&gt;();
          for(int i=0;i&lt;documents.length;i++){
            createchildwidget.add(TheGridview().makeGridCell(makeGridCell(data[i].data['message'], Icons.access_alarm));
  
          }
          return createchildwidget;
        }
  
  
      }
  </code></pre>