Ad
Flutter Firestore - Streambuilder Within A Streambuilder
I am trying to calculate the number of unread messages. In the first streambuilder I need to get all the document id's which match the first query.
Within that document ID I can then access the subcollection within that document and perform another query. I then need to access the result of that query.
However, within the attempt below the console outputs "past first stream" but does not enter the second streambuilder.
return StreamBuilder(
stream: Firestore.instance
.collection('conversations')
.where('user_id', isEqualTo: Provider.of<User>(context).id)
.snapshots(),
builder: (context, snapshot) {
if (!snapshot.hasData)
return Center(child: CircularProgressIndicator());
else {
print('past first stream');
StreamBuilder(
stream: Firestore.instance
.collection('conversations')
.document('#32#0#')
.collection('messages')
.where('customer_message_read', isEqualTo: false)
.snapshots(),
builder: (context, snapshot) {
print('im through second stream');
if (!snapshot.hasData)
return Center(child: CircularProgressIndicator());
print('nope');
QuerySnapshot querySnap = snapshot.data;
print(querySnap.documents.length);
return Center(child: CircularProgressIndicator());
},
);
return Scaffold(
backgroundColor: Colors.black,
body: _children[_selectedPage],
bottomNavigationBar: _bottomNavigationBar(context),
resizeToAvoidBottomPadding: true,
);
}
},
);
Ad
Answer
You've created second StreamBuilder
but did not return it
Ad
source: stackoverflow.com
Related Questions
- → How can I query Firebase for an equalTo boolean parameter?
- → How can I access nested data in Firebase with React?
- → Firebase simple blog (confused with security rules)
- → Removing item in Firebase with React, re-render returns item undefined
- → AngularJS Unknown Provider Error (Firebase & AngularFire)
- → How do you pass top level component state down to Routes using react-router?
- → "this" is null in firebase query function in reactjs
- → Angular Module Failed to Load
- → Multiple dex files define Lcom/google/android/gms/internal/zzrx;
- → Joining Firebase tables in React
- → How can I make add firepad to my reactjs project?
- → How to use Cloud Functions for Firebase to prerender pages for SEO?
- → React.js component has null state?
Ad