Nested Child Key Query In Firebaseanimatedlist
My Firebase Structure is like this: I want to get 'groupName' list in FirebaseAnimatedList. How to achive this? My current code: chatGroupNameReference = FirebaseDatabase.instance
Solution 1:
For nested child key query we need FutureBuilder with FirebaseAnimatedList:
chatGroupNameReference = FirebaseDatabase.instance.reference().child("chat_group_message_user_info").child(widget.user.uid);
body: new FirebaseAnimatedList(
defaultChild: Center(child: new CircularProgressIndicator()),
query: chatGroupNameReference,
sort: (a,b) => (b.key.compareTo(a.key)),
itemBuilder: (_, DataSnapshot messageSnapshot, Animation<double> animation, int index) {
returnnew FutureBuilder<DataSnapshot>(
future: chatGroupNameReference.child(messageSnapshot.key).once(),
builder: (BuildContext context, snapshot){
return snapshot.hasData ? new Text(snapshot.data.value['groupName']) : new Text("");
},
);
},
Solution 2:
(_, DataSnapshot messageSnapshot,
Animation<double> animation, int index)
After that line you can use FutureBuilder
to get data from your Firebase Database.
For example like that In a firebase animated list, is there a way to let firebase list know the expected height of a widget before it loads?
Post a Comment for "Nested Child Key Query In Firebaseanimatedlist"