【问题标题】:NullPointerException flutter_local_notifications does not work after Version-UpdateNullPointerException flutter_local_notifications 在版本更新后不起作用
【发布时间】:2021-12-26 02:03:19
【问题描述】:

我刚刚将我的 Flutter Local Notification Plugin https://pub.dev/packages/flutter_local_notifications 更新到旧项目中的最新版本(9.1.1),因为 schedule 方法已被宣布弃用。因此我使用了新的 Method 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$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)

有谁知道为什么现在触发了这个问题,但之前一切都很好?

【问题讨论】:

    标签: flutter flutter-dependencies flutter-local-notification


    【解决方案1】:

    版本 9.1.1 中存在 NPE 问题。新版本已修复此问题。

    [9.1.2] [Android] 修复 9.1.1 中引入的更改中的 NPE 问题 1378,以更新通知写入共享首选项的方式

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-11-26
      • 2017-05-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-12-17
      相关资源
      最近更新 更多