NullPointerException flutter_local_notifications 在版本更新后不起作用
NullPointerException flutter_local_notifications does not work after Version-Update
我刚刚将我的 Flutter 本地通知插件 https://pub.dev/packages/flutter_local_notifications 更新到旧项目中的最新版本 (9.1.1),因为 schedule 方法已被宣布弃用。因此我使用了新方法 zonedSchedule 。
我从文档中获取了 zonedSchedule 示例进行测试,但现在每次安排通知时都会出现异常:
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);
这是例外
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.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)
有谁知道为什么现在触发这个问题,但之前一切正常?
版本 9.1.1 中存在 NPE 问题。它已在新版本中修复。
[9.1.2]
[Android] 修复了 9.1.1 中引入的更改中的 NPE 问题 1378,更新了将通知写入共享首选项的方式
我刚刚将我的 Flutter 本地通知插件 https://pub.dev/packages/flutter_local_notifications 更新到旧项目中的最新版本 (9.1.1),因为 schedule 方法已被宣布弃用。因此我使用了新方法 zonedSchedule 。
我从文档中获取了 zonedSchedule 示例进行测试,但现在每次安排通知时都会出现异常:
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);
这是例外
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.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)
有谁知道为什么现在触发这个问题,但之前一切正常?
版本 9.1.1 中存在 NPE 问题。它已在新版本中修复。
[9.1.2] [Android] 修复了 9.1.1 中引入的更改中的 NPE 问题 1378,更新了将通知写入共享首选项的方式