title: Flutter Async: Future.wait() constantly returning null
body: <p>For some reason, <code>Future.wait()</code> is constantly returning <code>null</code>. I'm not completely certain I am using it correctly.</p>
  <p>For context, I have a collection of <code>posts</code> in Firebase. For each post, I can extract the <code>userID</code> assigned to it, then for each post individually I use the <code>userID</code> of the poster to grab the <code>username</code> for display purposes. I grab the <code>Post</code> from a snapshot:</p>
  <pre class="lang-dart prettyprint-override"><code>static Future&lt;Post&gt; fromSnapshot(QueryDocumentSnapshot&lt;Object?&gt; doc) async {
      final _documentId = doc.id;
      final _title = doc.get('title');
      final _text = doc.get('text');
      final _createdOn = doc.get('createdOn');
      final _userID = doc.get('userID');
  
      final userDoc = await FirebaseFirestore.instance.collection('users').doc(_userID).get();
      final username = userDoc.get(&quot;username&quot;);
  
      return Post(documentId: _documentId, title: _title, text: _text, createdOn: _createdOn, username: username);
    }
  </code></pre>
  <p>and the extraction of <code>posts</code> occurs in a <code>getPosts()</code> function elsewhere:</p>
  <pre class="lang-dart prettyprint-override"><code>Future&lt;List&lt;Post&gt;&gt; getPosts() async {
      QuerySnapshot posts = await FirebaseFirestore.instance.collection('posts').get();
  
      final allData = posts.docs.map(
              (doc) async =&gt; await Post.fromSnapshot(doc)
      ).toList();
  
      print(allData);                             // [Instance of 'Future&lt;Post&gt;', Instance of 'Future&lt;Post&gt;', Instance of 'Future&lt;Post&gt;']
  
      final futurePosts = Future.wait(allData);
      print(futurePosts);                         // Instance of 'Future&lt;List&lt;Post&gt;&gt;'
  
      // why does this always return null?
      return futurePosts;
    }
  </code></pre>
  <p>the problem is it has to be async to extract the posts but also to get the username, meaning it returns a future list of future posts. I want to pass the result of <code>getPosts()</code> to a <code>FutureBuilder</code>, so I need a <code>Future List</code> of posts, and to not make all the posts <code>Future</code> I use <code>Future.wait</code> - but that always seems to return null. Essentially, I am mapping each post in the snapshot to its own <code>Post</code> item, where in the constructor it needs to run a further <code>async</code> call to extract the <code>username</code>. Am I missing something?</p>
  <p>Note: even making the <code>Future.wait()</code> <code>await</code> returns <code>null</code>, it just also doesn't return a <code>List</code> of type <code>Future</code> so I can't use it in the <code>FutureBuilder</code> either.</p>
  <p>Edit 1:
  It turns out that <code>futurePosts</code> is actually an <code>Instance of 'Future&lt;List&lt;Post&gt;&gt;'</code>, but when accessing the data within the FutureBuilder, <code>snapshot.data</code> is <code>null</code>:</p>
  <pre class="lang-dart prettyprint-override"><code>@override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Feed'),
      ),
      body: FutureBuilder(
          future: getPosts(),
          builder: (context, snapshot) {
            if (snapshot.connectionState == ConnectionState.done) {
              print(snapshot.data);
              return postsToColumn(context, snapshot.data as List&lt;Post&gt;);
            }
            return const Center(
              child: CircularProgressIndicator(),
            );
          }
      ),
    );
  }
  </code></pre>