onMessage property

Returns a Stream that is called when an incoming FCM payload is received whilst the Flutter instance is in the foreground.

To handle messages whilst the app is in the background or terminated, see onBackgroundMessage.

Implementation

static StreamController<RemoteMessage> get onMessage {
  return _onMessageStreamController ??=
      StreamController<RemoteMessage>.broadcast();
}