title: Unhandled Exception: NoSuchMethodError: The method 'toRawHandle' was called on null
body: <p>i am using <b>firebase_messaging</b> library in My Flutter Application for Firebase Push Notifications.</p>
  
  <p>Currently my firebase_messaging version is <b>firebase_messaging: ^5.1.5</b> which was recently updated an the latest one.</p>
  
  <p>i am trying to receive notification in background as well as when application is terminated.</p>
  
  <p>i have followed all the steps as mentioned in the documentation of firebase_messaging but unfortunately i am getting the above error in flutter.</p>
  
  <p>this is my notification handler class in dart</p>
  
  <p><b>notification_handler.dart</b></p>
  
  <pre><code>import 'dart:async';
  import 'dart:io';
  import 'dart:math';
  
  import 'package:firebase_messaging/firebase_messaging.dart';
  import 'package:flutter/cupertino.dart';
  import 'package:flutter_local_notifications/flutter_local_notifications.dart';
  import 'package:path_provider/path_provider.dart';
  import 'package:http/http.dart' as http;
  
  class NotificationHandler {
    FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin;
    FirebaseMessaging _fcm = FirebaseMessaging();
    StreamSubscription iosSubscription;
    static final NotificationHandler _singleton =
        new NotificationHandler._internal();
  
    factory NotificationHandler() {
      return _singleton;
    }
    NotificationHandler._internal();
  
    Future&lt;dynamic&gt; myBackgroundMessageHandler(
        Map&lt;String, dynamic&gt; message) async {
      print("onLaunch: $message");
      _showBigPictureNotification(message);
      // Or do other work.
    }
  
    initializeFcmNotification() async {
      flutterLocalNotificationsPlugin = new FlutterLocalNotificationsPlugin();
  
      var initializationSettingsAndroid =
          new AndroidInitializationSettings('ic_launcher');
      var initializationSettingsIOS = new IOSInitializationSettings(
          onDidReceiveLocalNotification: onDidReceiveLocalNotification);
      var initializationSettings = new InitializationSettings(
          initializationSettingsAndroid, initializationSettingsIOS);
      flutterLocalNotificationsPlugin.initialize(initializationSettings,
          onSelectNotification: onSelectNotification);
  
      if (Platform.isIOS) {
        iosSubscription = _fcm.onIosSettingsRegistered.listen((data) {
          // save the token  OR subscribe to a topic here
        });
  
        _fcm.requestNotificationPermissions(IosNotificationSettings());
      } else {
        _saveDeviceToken();
      }
  
      _fcm.configure(
        onMessage: (Map&lt;String, dynamic&gt; message) async {
          print("onMessage: $message");
          _showBigPictureNotification(message);
        },
        onBackgroundMessage: myBackgroundMessageHandler,
        onLaunch: (Map&lt;String, dynamic&gt; message) async {
          print("onLaunch: $message");
        },
        onResume: (Map&lt;String, dynamic&gt; message) async {
          print("onResume: $message");
        },
      );
    }
  
    /// Get the token, save it to the database for current user
    _saveDeviceToken() async {
      String fcmToken = await _fcm.getToken();
      print("FCM_TOKEN: $fcmToken");
    }
  
    Future&lt;void&gt; _showBigPictureNotification(message) async {
      var rng = new Random();
      var notifId = rng.nextInt(100);
  
      var largeIconPath = await _downloadAndSaveImage(
          'https://cdn.pixabay.com/photo/2019/04/21/21/29/pattern-4145023_960_720.jpg',
          'largeIcon');
      var bigPicturePath = await _downloadAndSaveImage(
          'https://cdn.pixabay.com/photo/2019/04/21/21/29/pattern-4145023_960_720.jpg',
          'bigPicture');
      var bigPictureStyleInformation = BigPictureStyleInformation(
          bigPicturePath, BitmapSource.FilePath,
          largeIcon: largeIconPath,
          largeIconBitmapSource: BitmapSource.FilePath,
          contentTitle: message['data']['title'],
          htmlFormatContentTitle: true,
          summaryText: message['data']['body'],
          htmlFormatSummaryText: true);
      var androidPlatformChannelSpecifics = AndroidNotificationDetails(
          '12', 'trading_id', message['data']['body'],
          importance: Importance.High,
          priority: Priority.High,
          style: AndroidNotificationStyle.BigPicture,
          styleInformation: bigPictureStyleInformation);
      var platformChannelSpecifics =
          NotificationDetails(androidPlatformChannelSpecifics, null);
      await flutterLocalNotificationsPlugin.show(
          notifId,
          message['data']['title'],
          message['data']['body'],
          platformChannelSpecifics,
          payload: message['data']['body']);
    }
  
    Future&lt;void&gt; _showBigTextNotification(message) async {
      var rng = new Random();
      var notifId = rng.nextInt(100);
      var bigTextStyleInformation = BigTextStyleInformation(
          message['data']['body'],
          htmlFormatBigText: true,
          contentTitle: message['data']['title'],
          htmlFormatContentTitle: true,
          summaryText: message['data']['body'],
          htmlFormatSummaryText: true);
      var androidPlatformChannelSpecifics = AndroidNotificationDetails(
          '12', 'trading_id', '',
          importance: Importance.High,
          priority: Priority.High,
          style: AndroidNotificationStyle.BigText,
          styleInformation: bigTextStyleInformation);
      var platformChannelSpecifics =
          NotificationDetails(androidPlatformChannelSpecifics, null);
      await flutterLocalNotificationsPlugin.show(
          notifId,
          message['data']['title'],
          message['data']['body'],
          platformChannelSpecifics,
          payload: message['data']['body']);
    }
  
    Future onSelectNotification(String payload) async {
      if (payload != null) {
        debugPrint('notification payload: ' + payload);
      }
      // await Navigator.push(
      //   context,
      //   new MaterialPageRoute(builder: (context) =&gt; new SecondScreen(payload)),
      // );
    }
  
    Future&lt;void&gt; onDidReceiveLocalNotification(
        int id, String title, String body, String payload) async {
      // display a dialog with the notification details, tap ok to go to another page
    }
  
    Future&lt;String&gt; _downloadAndSaveImage(String url, String fileName) async {
      var directory = await getApplicationDocumentsDirectory();
      var filePath = '${directory.path}/$fileName';
      var response = await http.get(url);
      var file = File(filePath);
      await file.writeAsBytes(response.bodyBytes);
      return filePath;
    }
  }
  </code></pre>
  
  <p>and i have called it like this in my home screen</p>
  
  <pre><code>   @override
    void initState() {
      // TODO: implement initState
      super.initState();
      new NotificationHandler().initializeFcmNotification();
    }
  </code></pre>