Last active
November 1, 2020 02:49
-
-
Save AshAman999/655294acce6c31cbb3ca64fe9cff1c7a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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