title: Flutter Firebase subscribe to multiple Firebase Cloud Messaging topics
body: <p>I am a relative beginner with Dart &amp; right now for my Flutter app I am unsure on how to properly subscribe to multiple topics at once to Firebase Cloud Messaging. I want to receive notifications whenever my Cloud Function sends notifications through FCM to these topics at a certain time interval. The FlutterFire documentation seems to say that the <strong>subscribe/unsubscribeToTopic</strong> methods return Futures, but what is the best way in Dart to resolve multiple futures? So far, I have thought of 2 options below:</p>
  <p><strong>Method 1</strong></p>
  <pre><code>Future&lt;void&gt; subscribeTopicV1(List&lt;int&gt; selectedUsers) async {
      for (var userId in selectedUsers) {
        await messaging.subscribeToTopic('$userId');
      }
  }
  </code></pre>
  <p>My understanding is this basically turns all the subscribe/unsubscribe topic operations from asynchronous to synchronous if in the parent I call subscribeTopicV1 like the following:</p>
  <pre><code>...
  if (shouldSubscribe) {
     await subscribeTopicV1
  }
  ...
  // OR
  if (shouldSubscribe) {
     subscribeTopicV1.then( () =&gt; {
        ... // do whatever
     })
  }
  </code></pre>
  <p>This should mean that I am waiting on each <strong>messaging.subscribeToTopic</strong> to return before I move on to subscribe the next topic?</p>
  <p><strong>Method 2</strong></p>
  <pre><code>Future&lt;void&gt; subscribeTopicV2(List&lt;int&gt; selectedUsers) async {
       Future.wait(selectedUsers
           .map((userId) =&gt; messaging.subscribeToTopic('$userId')));
  }
  </code></pre>
  <p>Now this second method would run all the <strong>messaging.subscribeToTopic</strong> operations in parallel and if I call subscribeTopicV2 in the same way like:</p>
  <pre><code>...
  if (shouldSubscribe) {
     await subscribeTopicV2
  }
  ...
  // OR
  if (shouldSubscribe) {
     subscribeTopicV2.then( () =&gt; {
        ... // do whatever
     })
  }
  </code></pre>
  <p>In this second method, I should be waiting for when all futures are resolved inside subscribeTopicV2? I would like to mention that I do not care about the order in which the topics are subscribed so is it fair to say in this case I should be going with Method 2 for optimal performance since that it allows me to execute those async operations in parallel? I can't find any documentation of how people deal with subscribing to multiple topics so any insight would be much appreciated!</p>