【发布时间】:2020-08-27 10:13:38
【问题描述】:
目前,onMessage 函数将显示一个 AlertDialog。此功能运行良好。
但是,我想在应用处于前台时显示一个小吃栏。
有人有这方面的例子吗?
我当前的初始化状态:
void initState() {
super.initState();
getCurrentUser();
extractMachineIDs(); //IGNORE
getMachineStatus(0); //IGNORE
_fcm.configure(
onMessage: (Map<String, dynamic> message) async {
print("onMessage: $message");
showDialog( // I WANT A SNACKBAR HERE INSTEAD
context: context,
builder: (context) => AlertDialog(
content: ListTile(
title: Text(message['notification']['title']),
subtitle: Text(message['notification']['body']),
),
actions: <Widget>[
FlatButton(
child: Text('DISMISS'),
onPressed: () => Navigator.of(context).pop(),
),
],
),
);
},
onLaunch: (Map<String, dynamic> message) async {
print("onLaunch: $message");
},
onResume: (Map<String, dynamic> message) async {
print("onResume: $message");
Navigator.pushNamed(context, AlertsNotifications.id);
},
);
}
【问题讨论】:
标签: flutter dart firebase-cloud-messaging