Thank you for reading my question. My English may not be good enough before I ask you a question.
I'm using a flutter and I have to bring the product collection and subcollection image together from the FireStore.
I succeeded get data, but I don't know how to use it as a streambuilder.
FirebaseFirestore.instance
.collection("products")
.get()
.then((value) async => {
for (DocumentSnapshot document in value.docs)
{
log(document.data().toString()),
await document.reference
.collection("images")
.get()
.then((value) => {
for (DocumentSnapshot document
in value.docs)
{
log(document.data().toString()),
}
}),
}
});
I looked for it for three days, but I couldn't find the answer. Please reply.
Have a nice day. Thank you.
The only way I have found to do this is to use 2 different streambuilders, naming each snapshot differently. Use one for the products collection, then images for the other. What I would recommend is to add a field of 'images' in your product document and make it an array of string types. This will allow you to reference the images straight from each product document
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.