I have get an index here but I want display it from first to last in image : I want to display "hello" first then the rest
code:
StreamBuilder(
stream: FirebaseFirestore.instance
.collection("groups")
.doc(groupId)
.snapshots(),
builder: (context, AsyncSnapshot<DocumentSnapshot> snapshot) {
var chats = snapshot.data?["chats"];
return ...)};
ListView.builder(
physics: const BouncingScrollPhysics(),
itemCount: chats.length,
shrinkWrap: true,
itemBuilder: (context, index) {
return Text(chats[index]),
}),
Basically I want to display the recently added string first.
CodePudding user response:
You have to reverse: ture
in your listView,
like this:
ListView.builder(
reverse:true,
physics: const BouncingScrollPhysics(),
itemCount: chats.length,
shrinkWrap: true,
itemBuilder: (context, index) {
return Text(chats[index]),
}),