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,
);
}
},
);
您已经创建了第二个StreamBuilder
但没有返回它
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.