问题描述
我正在使用 FCM 在我的应用程序上发送推送通知,在我的设备通知栏上单击通知时一切正常,它会将我路由回应用程序并显示一个对话框,其中包含通知的更多详细信息。但是,当我终止应用程序并发送一个推送通知将我路由回应用程序,而不是向我显示包含通知的更多详细信息的对话框时,我收到以下错误“NoSuchMethodError The method '+' was called on null”。下面是我的 onMessage、onResume 和 Onlaunch。
@override
void initState() {
// TODO: implement initState
super.initState();
final FirebaseMessaging firebaseMessaging = FirebaseMessaging();
firebaseMessaging.configure(
onMessage: (Map<String,dynamic> message) async {
item_id= message['data']['item_id'].toString();
type_id= message['data']['type_id'].toString();
item_title= message['data']['item_title'].toString();
item_description= message['data']['item_description'].toString();
item_thumbnail_name= message['data']['item_thumbnail_name'].toString();
if(type_id=='1' ){
showGeneralDialog(
barrierLabel: "General Information",barrierDismissible: false,barrierColor: Colors.black.withOpacity(0.5),transitionDuration: Duration(milliseconds: 1200),context: context,pageBuilder: (context,anim1,anim2) {
return Align(
alignment: Alignment.bottomCenter,child: Container(
height: 400,child: SingleChildScrollView(child:Column(children: [
SizedBox(height: 10,),Center(child:Container(
padding: EdgeInsets.all(10),child: Row(
mainAxisAlignment: MainAxisAlignment.center,crossAxisAlignment: CrossAxisAlignment.center,children: [
Container(
padding: EdgeInsets.all(0),child:Material(
color: Colors.white,child:Text("Information!",style:TextStyle(
fontFamily: 'Montserrat',fontSize: 20.0,color: Colors.black,fontWeight: FontWeight.bold)
))),],))),Container(
padding: EdgeInsets.all(5),child:Material(
color: Colors.white,child:Column(
mainAxisSize: MainAxisSize.min,children: [
Stack(children: [
Image.asset("assets/640x360.png",fit: BoxFit.cover,height: 180,Image.network(item_thumbnail_name),Center(child:Padding(
padding: EdgeInsets.only(top: 5,bottom: 5),child: Text(item_title,style: TextStyle(
fontFamily: 'Montserrat',color: Colors.pink,fontSize: 15,fontWeight: FontWeight.bold),Padding(
padding: EdgeInsets.only(top: 5,child: Text(item_description+"...",maxLines: 4,color: Colors.grey,fontSize: 12,fontWeight: FontWeight.normal),)),Container(
padding: EdgeInsets.only(left:5,right:5),child:Row(
children: <Widget>[
Expanded(child:RaisedButton(
color: Colors.blue,onPressed: () { Navigator.pop(context,false);
},textColor: Colors.white,padding: const EdgeInsets.all(0.0),child: Container(
decoration: const BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(3)),color: Colors.blue,padding: const EdgeInsets.all(10.0),child:
const Text('Close',margin: EdgeInsets.only(bottom: 50,left: 12,right: 12),decoration: BoxDecoration(
color: Colors.white,borderRadius: BorderRadius.circular(20),);
},transitionBuilder: (context,anim2,child) {
return SlideTransition(
position: Tween(begin: Offset(0,1),end: Offset(0,0)).animate(anim1),child: child,);
}
}
onResume: (Map<String,dynamic> message) async {
if(type_id=='1' ){
showGeneralDialog(
barrierLabel: "General Information",);
}
} onLaunch: (Map<String,dynamic> message) async {
if(type_id=='1' ){
showGeneralDialog(
barrierLabel: "General Information",);
}
}
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)