title: Get the value of the Future<Map<String,String>> in FutureBuilder
body: <p>I have a Future method like below: </p>
  
  <pre><code>Future&lt;Map&lt;String,String&gt;&gt; readFavorites() async {
      SharedPreferences prefs = await SharedPreferences.getInstance();
      names = prefs.getKeys();
      for (var key in names) {
        debugPrint("key is " + key);
        debugPrint("value is " + prefs.get(key));
        pairs.putIfAbsent(key, () =&gt; prefs.get(key));
      }
      return pairs;
    }
  </code></pre>
  
  <p>I want to get the snapshot length plus the map's values in the futurebuilder below: </p>
  
  <pre><code> Widget build(BuildContext ctxt) {
      return Container(
        child: FutureBuilder(
          future: readFavorites(),
          builder: (context, AsyncSnapshot&lt;Map&lt;String,String&gt;&gt; snapshot) {
            if (snapshot.connectionState == ConnectionState.waiting) {
              return Center(
                //replace this with a loading icon
                  child: new CircularProgressIndicator());
            } else {
              return ListView.builder(
                  itemExtent: 90,
                  itemCount: snapshot.data.length, &lt;== How to get the map length? 
                  itemBuilder: (BuildContext context, int index) {
                    return SingleDish(
                      dish_name: snapshot.data[index],
                      dish_picture: snapshot.data[index]., &lt;== How to get the value from the map? 
                    );
                  });
            }
          },
        ),
      );
    }
  </code></pre>
  
  <p>I tried the following but I got a null exception: snapshot.data[snapshot.data[index]]. Will appreciate any help. </p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>What is interesting is that when I printed the key I got the following: </p>
  
  <p><strong>lib_cached_image_data_last_clean</strong></p>
  
  <pre><code>  Future&lt;Map&lt;String, String&gt;&gt; readFavorites() async {
      SharedPreferences prefs = await SharedPreferences.getInstance();
      names = prefs.getKeys();
      //This  returned  the correct value because I hardcoded the key
      print("hardcoded key is " + prefs.getString("Cutlet"));
      for (var key in names) {
        //This fellow here returned lib_cached_image_data_last_clean
        print("key is" + key);
         pairs.putIfAbsent(key, () =&gt; prefs.get(key));
       // print("key is "  + pairs.length.toString());
      }
      return pairs;
    }
  </code></pre>
  
  <p>So, I know for a fact that readFavorites() returns values. But am not sure why the key is not what I added in the SharedPreferences. </p>