{
"centers": {
"DCSE": {
"centerName": "DC"
},
"SE": {
"centerName": "ccc"
},
}
}
stdRef =FirebaseDatabase.instance.ref().child('centers').child('centerName');
i would like to access centerName without knowing its nodes names DCSE and SE as its possible to do? i want to access centerName with parent name cneter
instead of centers.DCSE.centerName
child('centers').child('centerName') directly????
If you don't know which center to show the name of, all you can do is show the name of all centers. That'd be something like:
final centersRef = FirebaseDatabase.instance.ref("centers");
centersRef.onValue.listen((event) {
for (final centerSnapshot in event.snapshot.children) {
print('${centerSnapshot.child("centerName").value}');
}
}, onError: (error) {
// Error.
});
Also see the Firebase documentation on listening for value events .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.