Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/flutter/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Flutter 颤振局部通知抛出方法#x27;显示';被调用为空_Flutter_Dart_Pusher - Fatal编程技术网

Flutter 颤振局部通知抛出方法#x27;显示';被调用为空

Flutter 颤振局部通知抛出方法#x27;显示';被调用为空,flutter,dart,pusher,Flutter,Dart,Pusher,我正在flutter中构建应用程序。我的应用程序的一部分包括通过Pusher发送数据,并通过Flatter_local_notifications library将数据显示给用户。目前,我正在尝试实现当我单击按钮时触发的颤振通知,但它只是抛出一个错误。目前我使用的是4.0.0版本的颤振本地通知 这是Notification.dart文件。这里我初始化了颤振本地通知的所有设置。 它还包括一个触发通知的函数(showNotification) 但当我尝试运行通知时,它会以 I/flutter ( 6

我正在flutter中构建应用程序。我的应用程序的一部分包括通过Pusher发送数据,并通过Flatter_local_notifications library将数据显示给用户。目前,我正在尝试实现当我单击按钮时触发的颤振通知,但它只是抛出一个错误。目前我使用的是4.0.0版本的颤振本地通知

这是Notification.dart文件。这里我初始化了颤振本地通知的所有设置。 它还包括一个触发通知的函数(showNotification)

但当我尝试运行通知时,它会以

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")