Reputation: 3
I have this simple data in Firebase Realtime Database:
Now i need to fetch data by using this code :
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.deepPurple,
appBar: AppBar(),
body: SingleChildScrollView(
child: FirebaseAnimatedList(
shrinkWrap: true,
query: FirebaseDatabase.instance.reference(),
itemBuilder: (BuildContext context, DataSnapshot snapshot,Animation<double> animation, int index) {
return Text(snapshot.value["name"]);
},),
),
);
}
With this code i will get two fields fetched in UI which are [name : Andy] and [name:Derek]
for more explain i screenshot this data
but How could i fetch only one field? Let's say i need to fetch only [name : Andy] which is under User 1 child.
Upvotes: 0
Views: 35
Reputation: 80914
Try the following:
FirebaseDatabase.instance.reference().child("User 1");
This will return the User 1
object
Upvotes: 1