title: How to get Metadata for Asynchronous Snapshot in Flutter
body: <p>So I am pulling data from Cloud Firestore but a bit stuck on checking to see whether the data is being retrieved via the cache or server. So to do this here is how I am pulling the data from cloud firestore</p>
  <pre><code>marketplacedata() async {
      try {
        var snapshot = await FirebaseFirestore.instance
            .collection('marketplaces')
            .doc('All')
            .collection('offers')
            .get();
  </code></pre>
  <p>I'm pulling the data from the init</p>
  <pre><code>class _SearchMarketplaceState extends State&lt;SearchMarketplace&gt; {
    void initState() {
      widget.futuredata = getData();
      super.initState();
    }
  
    getData() async {
      return await FireStoreData().marketplacedata('All');
    }
  </code></pre>
  <p>Then I am using future builder to retrieve the data as such</p>
  <pre><code>FutureBuilder(
                  future: widget.futuredata,
                  builder: (BuildContext context, AsyncSnapshot snapshot) {
                    var marketplacedata = snapshot.data;
  
                    if (snapshot.hasError) {
                      return Text('something went wrong');
                    }
  
                    **if (snapshot.hasData) {
                      HOW DO I CHECK WHETHER THE DATA IS COMING FROM CACHE?);
                      .metadata doesnt work on AsyncSnapShot
  
  
                    }**
  
                    if (searchController.text.isNotEmpty) {
                      marketplacedata = searchFilter(
                          searchController.text.toLowerCase(), marketplacedata);
                    }
                    if (snapshot.connectionState == ConnectionState.waiting) {
                      return Loading();
                    } else {
                      return GridView.builder(
                        gridDelegate:
                            const SliverGridDelegateWithFixedCrossAxisCount(
                          crossAxisCount: 3,
                          childAspectRatio: (4 / 4),
                        ),
                        itemCount: marketplacedata.length ?? 1,
                        itemBuilder: (BuildContext context, int index) {
                          return buildMarketplace(context, index,
                              marketplaceID: marketplacedata[index].marketplaceID,
                              heading: marketplacedata[index].heading,
                              companyDesc: marketplacedata[index].companyDesc,
                              iconURL: marketplacedata[index].iconURL,
                              keywords: marketplacedata[index].keywords,
                              preferred: marketplacedata[index].preferred,
                              imgURL: marketplacedata[index].imgURL);
                        },
                      );
                    }
                  },
                ),
  </code></pre>
  <p>Any help is appreciated. In the end I am trying to minimize the number of reads I am getting and hoping to get most of the data read from the cache. However I cant seem to access any data. Thanks in advance.</p>