Skip to content

Instantly share code, notes, and snippets.

@AshAman999
Last active November 1, 2020 02:49
Show Gist options
  • Save AshAman999/655294acce6c31cbb3ca64fe9cff1c7a to your computer and use it in GitHub Desktop.
Save AshAman999/655294acce6c31cbb3ca64fe9cff1c7a to your computer and use it in GitHub Desktop.
// stream builder in dart using the new firebase commands
StreamBuilder<QuerySnapshot>(
stream: _firestore.collection('messages').snapshots(),
builder: (context, snapshot) {
if (snapshot.hasData) {
final messages = snapshot.data.docs;
List<Text> messageWidget = [];
for (var message in messages) {
final messageText = message.get('text');
final messageSender = message.get('sender');
final messagewidg = Text('$messageText from '
'$messageSender');
messageWidget.add(messagewidg);
}
return Column(
children: messageWidget,
);
}
return Text('some error occurred');
},
),
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment