'Where to write the logic to upload FCM token or to subscribe to any topic while using FCM service with Firebase?

I am new to flutter and Firebase. I have registered my android app with firebase. My final goal is to send notifications to all the users automatically with a cloud function. So far, I know either I need to store the list of FCM tokens of all the users or subscribe them to perticular topic. I was thinking of going with subscribing to the topic, so that I will not have to store the tokens in my firestore. So, my question is where should I write

FirebaseMessaging.instance.subscribeToTopic("drawNotifications");

Because, If I put it in the main or initState, then it will be called everytime the user runs the app and if I do so, is it the right way to? Please feel free to let me know if I need to explain it more clearly as this is my very first question in Stackoverflow.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source