'[flutter/FCM]problem receiving notification

I'm using flutter and Firebasemessaging to send and receive notification and the plugging FlutterLocalNotifications to display them.

but when I receive the notification I get the error :

D/FLTFireMsgReceiver(23943): broadcast received for message
E/MethodChannel#dexterous.com/flutter/local_notifications(23943): Failed to handle method call
E/MethodChannel#dexterous.com/flutter/local_notifications(23943): java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.Integer.intValue()' on a null object reference
E/MethodChannel#dexterous.com/flutter/local_notifications(23943):   at com.dexterous.flutterlocalnotifications.FlutterLocalNotificationsPlugin.setSmallIcon(FlutterLocalNotificationsPlugin.java:308)
E/MethodChannel#dexterous.com/flutter/local_notifications(23943):   at com.dexterous.flutterlocalnotifications.FlutterLocalNotificationsPlugin.createNotification(FlutterLocalNotificationsPlugin.java:219)
E/MethodChannel#dexterous.com/flutter/local_notifications(23943):   at com.dexterous.flutterlocalnotifications.FlutterLocalNotificationsPlugin.showNotification(FlutterLocalNotificationsPlugin.java:1013)
E/MethodChannel#dexterous.com/flutter/local_notifications(23943):   at com.dexterous.flutterlocalnotifications.FlutterLocalNotificationsPlugin.show(FlutterLocalNotificationsPlugin.java:1354)
E/MethodChannel#dexterous.com/flutter/local_notifications(23943):   at com.dexterous.flutterlocalnotifications.FlutterLocalNotificationsPlugin.onMethodCall(FlutterLocalNotificationsPlugin.java:1230)
E/MethodChannel#dexterous.com/flutter/local_notifications(23943):   at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:262)
E/MethodChannel#dexterous.com/flutter/local_notifications(23943):   at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:295)
E/MethodChannel#dexterous.com/flutter/local_notifications(23943):   at io.flutter.embedding.engine.dart.DartMessenger.lambda$dispatchMessageToQueue$0$DartMessenger(DartMessenger.java:319)
E/MethodChannel#dexterous.com/flutter/local_notifications(23943):   at io.flutter.embedding.engine.dart.-$$Lambda$DartMessenger$TsixYUB5E6FpKhMtCSQVHKE89gQ.run(Unknown Source:12)
E/MethodChannel#dexterous.com/flutter/local_notifications(23943):   at android.os.Handler.handleCallback(Handler.java:938)
E/MethodChannel#dexterous.com/flutter/local_notifications(23943):   at android.os.Handler.dispatchMessage(Handler.java:99)
E/MethodChannel#dexterous.com/flutter/local_notifications(23943):   at android.os.Looper.loop(Looper.java:223)
E/MethodChannel#dexterous.com/flutter/local_notifications(23943):   at android.app.ActivityThread.main(ActivityThread.java:7656)
E/MethodChannel#dexterous.com/flutter/local_notifications(23943):   at java.lang.reflect.Method.invoke(Native Method)
E/MethodChannel#dexterous.com/flutter/local_notifications(23943):   at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
E/MethodChannel#dexterous.com/flutter/local_notifications(23943):   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
E/flutter (23943): [ERROR:flutter/lib/ui/ui_dart_state.cc(198)] Unhandled Exception: PlatformException(error, Attempt to invoke virtual method 'int java.lang.Integer.intValue()' on a null object reference, null, java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.Integer.intValue()' on a null object reference
E/flutter (23943):  at com.dexterous.flutterlocalnotifications.FlutterLocalNotificationsPlugin.setSmallIcon(FlutterLocalNotificationsPlugin.java:308)
E/flutter (23943):  at com.dexterous.flutterlocalnotifications.FlutterLocalNotificationsPlugin.createNotification(FlutterLocalNotificationsPlugin.java:219)
E/flutter (23943):  at com.dexterous.flutterlocalnotifications.FlutterLocalNotificationsPlugin.showNotification(FlutterLocalNotificationsPlugin.java:1013)
E/flutter (23943):  at com.dexterous.flutterlocalnotifications.FlutterLocalNotificationsPlugin.show(FlutterLocalNotificationsPlugin.java:1354)
E/flutter (23943):  at com.dexterous.flutterlocalnotifications.FlutterLocalNotificationsPlugin.onMethodCall(FlutterLocalNotificationsPlugin.java:1230)
E/flutter (23943):  at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:262)
E/flutter (23943):  at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:295)
E/flutter (23943):  at io.flutter.embedding.engine.dart.DartMessenger.lambda$dispatchMessageToQueue$0$DartMessenger(DartMessenger.java:319)
E/flutter (23943):  at io.flutter.embedding.engine.dart.-$$Lambda$DartMessenger$TsixYUB5E6FpKhMtCSQVHKE89gQ.run(Unknown Source:12)
E/flutter (23943):  at android.os.Handler.handleCallback(Handler.java:938)
E/flutter (23943):  at android.os.Handler.dispatchMessage(Handler.java:99)
E/flutter (23943):  at android.os.Looper.loop(Looper.java:223)
E/flutter (23943):  at android.app.ActivityThread.main(ActivityThread.java:7656)
E/flutter (23943):  at java.lang.reflect.Method.invoke(Native Method)
E/flutter (23943):  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
E/flutter (23943):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
E/flutter (23943): )
E/flutter (23943): #0      StandardMethodCodec.decodeEnvelope
E/flutter (23943): #1      MethodChannel._invokeMethod
E/flutter (23943): <asynchronous suspension>
E/flutter (23943): #2      FlutterLocalNotificationsPlugin.show
E/flutter (23943): <asynchronous suspension>
E/flutter (23943):


Solution 1:[1]

The solution is that I need to add the icon path when I set AndroidNotificationDetails.

static Future _notificationDetails() async {
    return NotificationDetails(
      android: AndroidNotificationDetails('channel id', 'channel name',
          channelDescription: 'channel description',
          importance: Importance.max,
  ==>     icon: "@mipmap/ic_launcher"),  <==
      iOS: IOSNotificationDetails(),
    );
  }

Sources

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

Source: Stack Overflow

Solution Source
Solution 1 ismail