title: Looping through Firestore is ignoring async await?
body: <p>So I have an app where I have images stored on Firebase Storage and I want to loop through a few records in my Firestore and create Containers() for each of them to be used in a PageView. However, when looping through it seems like the AWAIT clues are ignored somehow?</p>
  <p>This is what I got:</p>
  <pre><code>loadDashboard() async {
      // Load data about breed in focus
      Map&lt;String, dynamic&gt; _documentData;
      _isLoadingArticles = true;
      _dashboardArticles.clear();
  
      int _articleCount = 0;
  
      await _firestore
          .collection('DashboardArticle')
          .where(&quot;active&quot;, isEqualTo: true)
          .get()
          .then((QuerySnapshot querySnapshot) {
        querySnapshot.docs.forEach((doc) {
          _articleCount++;
  
          downloadURL(doc[&quot;image&quot;]);
          print(doc[&quot;title&quot;]);
  
          _dashboardArticles.add(
            Padding(
              padding: EdgeInsets.fromLTRB(5, 0, 5, 0),
              child: Stack(
                children: [
                  ClipRRect(
                    borderRadius: BorderRadius.circular(15),
                    child: Image(
                      image: NetworkImage(
                        _articleImgUrl,
                      ),
                      alignment: Alignment.center,
                      width: double.infinity,
                      fit: BoxFit.cover,
                    ),
                  ),
                  Padding(
                    padding: EdgeInsets.fromLTRB(20, 10, 0, 0),
                    child: Column(
                      crossAxisAlignment: CrossAxisAlignment.start,
                      children: [
                        SizedBox(height: 25),
                        Text(
                          doc[&quot;title&quot;],
                          style: TextStyle(
                              shadows: [
                                Shadow(
                                  blurRadius: 10.0,
                                  color: Colors.black,
                                  offset: Offset(1.0, 1.0),
                                ),
                              ],
                              color: Colors.white,
                              fontSize: 20,
                              fontWeight: FontWeight.bold),
                        ),
                        SizedBox(height: 5),
                        Text(
                          doc[&quot;tagline&quot;],
                          style: TextStyle(
                            color: Colors.white,
                            fontSize: 16,
                            shadows: [
                              Shadow(
                                blurRadius: 10.0,
                                color: Colors.black,
                                offset: Offset(1.0, 1.0),
                              ),
                            ],
                          ),
                        )
                      ],
                    ),
                  ),
                ],
              ),
            ),
          );
  
          setState(() {
            _isLoadingArticles = false;
            _totalArticleDots = _articleCount;
          });
         
        });
      }).catchError((e) =&gt; print(&quot;error fetching data: $e&quot;));
    }
  
    Future&lt;String&gt; downloadURL(String image) async {
      await firebase_storage.FirebaseStorage.instance
          .ref('dashboard_article_images/$image')
          .getDownloadURL()
          .then((value) =&gt; {
                setState(() {
                  _articleImgUrl = value;
                  print(_articleImgUrl);
                })
              })
          .catchError((e) =&gt; {
                setState(() {
                  _articleImgUrl = &quot;&quot;;
                })
              });
  
      return &quot;&quot;;
    }
  </code></pre>
  <p>_articleImgUrl is a variable outside that I set as I'm not sure how to get the String value from the Future in any other way.</p>
  <p>Each PRINT shows the data in correct order, for example:</p>
  <pre><code>flutter: Pooch in focus: Corgi
  flutter: https://firebasestorage.googleapis.com:443/v0/b/.../o/article_images%2F4f3... (I truncated here)
  </code></pre>
  <p>When I se breakpoints it seems that _articleImgUrl has no value at the time the _dashboardArticles.add(...) is executed, so it feels like the awaits are skipped when looping somehow?</p>
  <pre><code>Invalid argument(s): No host specified in URI file:///
  </code></pre>
  <p>Can anyone provide insights? Thanks!</p>