I wanna fetch recent inserted data in firebase real-time database, it can be on a top or bottom. basically I have created a card in flutter, instead of list of data I wanna replace the recent inserted database in a app with old data.
Query dbref = FirebaseDatabase.instance.ref().child("post");
Container(
height: 200,
width: 400,
child: FirebaseAnimatedList(
query: dbref,
itemBuilder: (BuildContext context,DataSnapshot snapshot,Animation<double> animation,int index)
{
Map data = snapshot.value as Map;
data['key'] = snapshot.key;
// return ListTile(
// title: Text(data[0]["title"].toString()),
// );
return li(data:data);
}
)
)
The listener receives a DataSnapshot that contains the data at the specified location in the database at the time of the event in its value property.
DatabaseReference starCountRef =
FirebaseDatabase.instance.ref().child("post");
starCountRef.onValue.listen((DatabaseEvent event) {
final data = event.snapshot.value;
updateStarCount(data);
});
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.