title: Flutter Futures: Waiting for listener to complete at least once
body: <p>I am trying to implement a future return on a function that contains a listener. I want to complete this future when the listener has returned data at least once. I am not using async/await because the listen function is not a future. Hence, my option is the following:</p>
  
  <pre><code>static Future listenForConsumption() async {
      Completer completer = Completer();
      try {
        kConsumptionCollection
            .where("userId", isEqualTo: User.current.id)
            .orderBy("consumptionDate", descending: true)
            .snapshots()
            .listen(
          (data) {
            consumptionList = data.documents
                .map((doc) =&gt; ConsumptionUnit.data(doc.documentID, doc.data))
                .toList();
            streamController.add(consumptionList);
            completer.complete();
          },
        );
      } catch (err) {
        completer.complete();
        throw (err);
      }
  
      return completer.future;
    }
  </code></pre>
  
  <p>By using a Completer I am trying to wait until the listener completes. However, the function that calls this one seems not to be awaiting for the future to complete:</p>
  
  <pre><code>void _checkForCurrentUser() async {
      try {
        await UserManager.fetchCurrentUser(); //Function waits for this
        await Future.wait([
           ConsumptionManager.listenForConsumption(),
           BottleManager.listenForBottles(),
        ]); //Function does not wait for this
  
        Navigator.push(
          context,
          MaterialPageRoute(builder: (context) =&gt; Home()),
        );
  
      } catch (err) {
        log("$err");
      }
  //...Rest of function
  </code></pre>
  
  <p>Any ideas of what can be missing?</p>