title: Flutter - iterate over an asynchrous/future list
body: <p>I'm trying to create a list with values obtained by SharedPreferences. However, if I want to use SharedPreference, I've to use async methods / future types and I have no idea how to work with them. I try to iterate over the <code>sports</code> list, but it is asynchronous/future. So how do I iterate over it (using map)?</p>
  <pre><code>class _MyHomePageState extends State&lt;MyHomePage&gt; {
  
    @override
    Widget build(BuildContext context) {
      return MaterialApp(
          Center(
            child: Align(
              alignment: Alignment.bottomCenter,
              child: CarouselSlider(
                options: CarouselOptions(
                  height: 565,
                  aspectRatio: 16/9,
                  enlargeCenterPage: true,
                  viewportFraction: .8,
                ),
                items: sportsList.map((i) {
                  return Builder(builder: (BuildContext context) {
                    return Container(
                      .......
                      .........
                      .......
  }
  
  
    static Future&lt;bool&gt; initSharedPreference(String key) async {
      final SharedPreferences prefs = await SharedPreferences.getInstance();
      
      return prefs.getBool(key) ?? false;
    }
  
  
    Future&lt;List&gt; sportsList() async {
      List sports=[
        await initSharedPreference(&quot;test&quot;)), 
          ....,
          ....,
          ....
      ];
    }
  </code></pre>
  <p>This code doesn't work because of the following:</p>
  <p><code>The method 'map' isn't defined for the type 'Future'.</code></p>