【发布时间】: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