title: Returning List from Firestore Listen callback
body: <p>I have a function in firebase that is intended to get all documents in a collection called <code>history</code> and add it to a list intended to be returned. </p>
  
  <p>The problem is, and I think this is because <code>.listen()</code> is async, the list returned is always empty. I know the data is queried correctly because I can print the doc in the <code>forEach</code> function, but adding to a list outside doesn't work.</p>
  
  <p>By the way, <code>myStream</code> is a snapshot of the history collection in FireStore.</p>
  
  <p>Does my function need to be a Future? How can I make this work? </p>
  
  <p>Here is my code:</p>
  
  <pre><code>List getHistory(String id) {
    List history;
  
    Firestore.instance.collection(id).snapshots().listen((data) {
      data.documents.forEach(
        (doc) =&gt; history.add(doc['day']),
      );
    });
  
    return history;
  }
  </code></pre>