Firebase Cloud Messaging (FCM) is a service that allows you to send notifications to your users. In Flutter, where you use the FlutterFire tools, this requires enabling the firebase_messaging package in your app.
To get an instance of the FirebaseMessaging class, you can use the following command:
FirebaseMessaging messaging = FirebaseMessaging.instance;
Like all services within FlutterFire, messaging services are available only after you initialize FirebaseApp. This is why you included the FirebaseMessaging configuration in the Firebase.initializeApp().whenComplete callback.
The onBackgroundMessage callback is triggered when a new notification message is received and takes the method that deals with the notification:
FirebaseMessaging.onBackgroundMessage(_firebaseBackgroundMessageReceived);
In the function you pass to the onBackgroundMessage callback, you could save the message in a local database or SharedPreferences, or take any other action over it. In this recipe...