I have this datasnapshot
"{post1: {pic: https://i.redd.it/ni6zhxh874011.jpg, title: title, desc: desc}, post2: {pic: https://i.redd.it/krj9miojg5011.jpg, title: awsdas, desc: desc2}}"
and I would like to retrieve the "pic" values from each post. snapshot.value["pic"] does not work it returns null.
thanks in advance
this is how I recieved the datasnapshot for my future builder
Future<Object> _obj () async {
Object _objdatabase;
await FirebaseDatabase.instance.reference().child("Communities").once().then((DataSnapshot snapshot) {
print(_objdatabase.toString());
_objdatabase = snapshot.value;
});
return _objdatabase;
}
here is what i did
Map<dynamic, dynamic> map = snapshot.data.snapshot.value;
map.values.toList()[index]["pic"]
if you are sure snapshot have child's use value member as Map Object
snapshot.value['key'];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With