Skip to content

Instantly share code, notes, and snippets.

@duytq94
Last active September 21, 2020 10:12
Show Gist options
  • Save duytq94/8903181be61b4de727bf71a566218acd to your computer and use it in GitHub Desktop.
Save duytq94/8903181be61b4de727bf71a566218acd to your computer and use it in GitHub Desktop.
StreamBuilder(
stream: Firestore.instance
.collection('messages')
.document(groupChatId)
.collection(groupChatId)
.orderBy('timestamp', descending: true)
.limit(_limit)
.snapshots(),
builder: (context, snapshot) {
if (!snapshot.hasData) {
return Center(
child: CircularProgressIndicator(valueColor: AlwaysStoppedAnimation<Color>(themeColor)));
} else {
listMessage = snapshot.data.documents;
return ListView.builder(
padding: EdgeInsets.all(10.0),
itemBuilder: (context, index) => buildItem(index, snapshot.data.documents[index]),
itemCount: snapshot.data.documents.length,
reverse: true,
controller: listScrollController,
);
}
},
),
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment