Flutter 颤振局部通知抛出方法#x27;显示';被调用为空
我正在flutter中构建应用程序。我的应用程序的一部分包括通过Pusher发送数据,并通过Flatter_local_notifications library将数据显示给用户。目前,我正在尝试实现当我单击按钮时触发的颤振通知,但它只是抛出一个错误。目前我使用的是4.0.0版本的颤振本地通知 这是Notification.dart文件。这里我初始化了颤振本地通知的所有设置。 它还包括一个触发通知的函数(showNotification) 但当我尝试运行通知时,它会以Flutter 颤振局部通知抛出方法#x27;显示';被调用为空,flutter,dart,pusher,Flutter,Dart,Pusher,我正在flutter中构建应用程序。我的应用程序的一部分包括通过Pusher发送数据,并通过Flatter_local_notifications library将数据显示给用户。目前,我正在尝试实现当我单击按钮时触发的颤振通知,但它只是抛出一个错误。目前我使用的是4.0.0版本的颤振本地通知 这是Notification.dart文件。这里我初始化了颤振本地通知的所有设置。 它还包括一个触发通知的函数(showNotification) 但当我尝试运行通知时,它会以 I/flutter ( 6
I/flutter ( 6968): NoSuchMethodError: The method 'show' was called on null.
I/flutter ( 6968): Receiver: null
I/flutter ( 6968): Tried calling: show(0, "plain title", "plain body", Instance of 'NotificationDetails', payload: "item x")
Future<void> main() async {
await NotificationService().init();
runApp(Router());
}
Widget build(BuildContext context) {
return Scaffold(
drawer: Draw.StudentDrawer(),
appBar: Nav.NavigationBar(),
body: ListView(
children: [
FlatButton(onPressed: () async {
await NotificationService().showNotification("TEST");
}, child: Text("test"))
],
),
);
}
}
I/flutter ( 6968): NoSuchMethodError: The method 'show' was called on null.
I/flutter ( 6968): Receiver: null
I/flutter ( 6968): Tried calling: show(0, "plain title", "plain body", Instance of 'NotificationDetails', payload: "item x")