当前,onMessage函数将显示一个AlertDialog。此功能正常工作。
但是,我想在应用程序处于前台时显示小吃栏。
有人有这个例子吗?
我当前的initState:
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);
},
);
}
答案 0 :(得分:1)
使用它代替const makeTree = (categories, parent) => {
const node = {};
categories
.filter(c => c.parentId === parent)
.forEach(c => {
node[c.id] = makeTree(categories, c.id);
Object.assign(node[c.id], c);
});
return node;
}
console.log(makeTree(mockData, null));
:
public ActionResult Index(UserData model)
{
try
{
// Pass the "personlist" object for conversion object to JSON string
string jsondata = new JavaScriptSerializer().Serialize(model);
string path = Server.MapPath("~/App_Data/output.json");
// Write that JSON to txt file,
System.IO.File.WriteAllText(path , jsondata);
TempData["msg"] = "Json file Generated! check this in your App_Data folder";
}
catch (Exception e) { }
return RedirectToAction("Index");
}