I want to display the documents in Firestore database in home screen by using snapshot
I need something like this
Text('documents["name"]')
CodePudding user response:
body: new StreamBuilder(
stream: Firestore.instance.collection("groups").snapshots(),
builder: (context, snapshot) {
if (!snapshot.hasData) {
return Text(
'No Data...',
);
} else {
<DocumentSnapshot> items = snapshot.data.documents;
return Text(items[0]["name"]);
}
CodePudding user response:
Use this code:
List<String> _groupsId = [];
await fireStore
.collection('groups')
.get()
.then((QuerySnapshot querySnapshot) {
for (var doc in querySnapshot.docs) {
_groupsId.add(doc.id);
}
});
You will get all list key of documents