NullPointerException flutter_local_notifications does not work after Version-Update

Issue

I just updated my Flutter Local Notification Plugin https://pub.dev/packages/flutter_local_notifications to the latest Release (9.1.1) in an old project because the schedule Method was declared deprecated. Therefore I used the new Method zonedSchedule .

I took the zonedSchedule example from the doc to test it but now there is an exception every time the Notification is scheduled:

 await flutterLocalNotificationsPlugin.zonedSchedule(
      0,
      'scheduled title',
      'scheduled body',
      tz.TZDateTime.now(tz.local).add(const Duration(seconds: 5)),
      const NotificationDetails(
          android: AndroidNotificationDetails(
              'your channel id', 'your channel name',
              channelDescription: 'your channel description')),
      androidAllowWhileIdle: true,
      uiLocalNotificationDateInterpretation:
      UILocalNotificationDateInterpretation.absoluteTime);

Here is the Exception

E/AndroidRuntime(15499): java.lang.NullPointerException: Attempt to invoke interface method 'void io.flutter.plugin.common.MethodChannel$Result.success(java.lang.Object)' on a null object reference
E/AndroidRuntime(15499):    at com.dexterous.flutterlocalnotifications.FlutterLocalNotificationsPlugin$2$1.run(FlutterLocalNotificationsPlugin.java:371)
E/AndroidRuntime(15499):    at android.os.Handler.handleCallback(Handler.java:938)
E/AndroidRuntime(15499):    at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime(15499):    at android.os.Looper.loop(Looper.java:223)
E/AndroidRuntime(15499):    at android.app.ActivityThread.main(ActivityThread.java:7656)
E/AndroidRuntime(15499):    at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(15499):    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
E/AndroidRuntime(15499):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)

Does anyone know why this problem is being triggered now but everything was fine before?

Solution

There was an NPE issue in Version 9.1.1. It’s fixed with the new release.

[9.1.2]
[Android] Fix NPE issue 1378 from change introduced in 9.1.1 in updating how notifications were written to shared preferences

Answered By – Robin.S

Answer Checked By – Dawn Plyler (FlutterFixes Volunteer)

Leave a Reply

Your email address will not be published. Required fields are marked *