I'm trying to perform a compound query in Cloud Firestore with the isEqualTo
operator in Flutter, inside a StreamBuilder
, like this:
Firestore.instance
.collection('produtos')
.where("NProduto", isEqualTo: productClicked)
.snapshots()
.listen((data) =>
data.documents.forEach((doc) => nomeProdutoClicked = doc["Nome"]));
But when i try to use forEach
in the last line, it never seems to add to a list, to set to a variable or anything like that, the only thing that worked was printing (doc)
.
I've tried doing it outside the StreamBuilder in a separate methos but I wasn't able to make it work in any way.
Essentially, what I'm trying to do is get a document from a different collection as that as the one I'm using in the StreamBuilder.
If you know another way to do this, or know how to solve this issue, please help me. I will be eternally grateful hahhahah :)