i want to get the Field “child” from the collection “Kinder”.
But only the actually one, not the whole collection.
StreamBuilder<QuerySnapshot>(
stream: FirebaseFirestore.instance
.collection("Users")
.doc(currentUser?.email)
.collection("Kinder")
.doc(widget.docID)
.snapshots(),
builder: (BuildContext context, AsyncSnapshot<QuerySnapshot> snapshot) {
if (snapshot.hasError) {
return Text('Something went wrong');
}
if (snapshot.connectionState == ConnectionState.waiting) {
return Text("Loading");
}
return ListView(
children: snapshot.data!.docs.map((DocumentSnapshot document) {
Map<String, dynamic> data = document.data()! as Map<String, dynamic>;
return ListTile(
title: Text(data['child']),
);
}).toList(),
);
},
),
Thanks!
With this Code i get the right collection but all “child” fields.
When i Add “.doc(widget.docID)” i need to add another “.collection(…)”?
New contributor
steste95 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.