Reputation: 27
I want to match the GroupIDs from two different Collections. How can i use the documentSnapshot inside the StreamBuilder?
@override
void initState() async{
// TODO: implement initState
super.initState();
chatReference =
db.collection("users").document(uid).collection('usergroups');
}
StreamBuilder<QuerySnapshot>(
stream: Firestore.instance
.collection('groups')
.where('GroupID', isEqualTo: documentSnapshot.data['GroupID'])
.snapshots(),
builder: (BuildContext context,
AsyncSnapshot<QuerySnapshot> snapshot) {
if (!snapshot.hasData) {
return new Text('Connecting...');
} else {
Upvotes: 0
Views: 76
Reputation: 1997
I think what you are looking for is a way to combine both the streams and output the data according to certain conditions. You can checkout CombineLatestStream from the rxdart which will allow you to pass both the stream as input and use combiner function to give the output. You can refer to the rxdart docs for more information on CombineLatestStream.
Hope this helps.
Upvotes: 1