Reputation: 234
So im recieving my notifiactions using firebase but I want to display each notification as a dynamic list view which appends new notifications. Also any information on how to use this class on the homepage also helps. Any help would be appreciated!
if (Platform.isIOS) {
iosSubscription = _fcm.onIosSettingsRegistered.listen((data) {
print(data);
_saveDeviceToken();
});
_fcm.requestNotificationPermissions(IosNotificationSettings());
} else {
_saveDeviceToken();
}
_fcm.configure(
onMessage: (Map<String, dynamic> message) async {
print("onMessage: $message");
// final snackbar = SnackBar(
// content: Text(message['notification']['title']),
// action: SnackBarAction(
// label: 'Go',
// onPressed: () => null,
// ),
// );
// Scaffold.of(context).showSnackBar(snackbar);
showDialog(
context: context,
builder: (context) => AlertDialog(
content: ListTile(
title: Text(message['notification']['title']),
subtitle: Text(message['notification']['body']),
),
actions: <Widget>[
FlatButton(
color: Colors.amber,
child: Text('Ok'),
onPressed: () => Navigator.of(context).pop(),
),
],
),
);
},
onLaunch: (Map<String, dynamic> message) async {
print("onLaunch: $message");
// TODO optional
},
onResume: (Map<String, dynamic> message) async {
print("onResume: $message");
// TODO optional
},
);
}
Upvotes: 1
Views: 555
Reputation: 1192
I think this might work
ListView.builder(
itemCount: null == messagesList ? 0 : messagesList.length,
itemBuilder: (BuildContext context, int index) {
return Card(
child: Padding(
padding: EdgeInsets.all(10.0),
child: Text(
messagesList[index].message,
style: TextStyle(
fontSize: 16.0,
color: Colors.black,
),
Upvotes: 1