所以,我想这样写查询
... where from = x or to =x
我找不到有关使用where条件的任何文档。因此,我使用StreamZip
@override
void initState() {
getEmail();
stream1 = databaseReference
.collection("userChat")
.where("from", isEqualTo: userId)
.orderBy("messageDate", descending: true)
.snapshots();
stream2 = databaseReference
.collection("userChat")
.where('to', isEqualTo: userId)
.orderBy("messageDate", descending: true)
.snapshots();
}
这是我的StreamBuilder
StreamBuilder(
stream: StreamZip([stream1, stream2]),
builder: (context, snapshot) {
print(snapshot.data.documents);
switch (snapshot.connectionState) {
case ConnectionState.none:
case ConnectionState.waiting:
return Center(
child: CircularProgressIndicator(),
);
default:
return new Flexible(
child: new ListView.builder(
controller: _scrollController,
padding: new EdgeInsets.all(8.0),
reverse: false,
itemBuilder: (context, index) {
print("Time to show data");
List rev = snapshot
.data.documents.reversed
.toList();
MessageFromCloud messageFromCloud =
MessageFromCloud.fromSnapshot(
rev[index]);
return new ChatMessage(
data: messageFromCloud,
userFullname: userFullname,
userId: userId,
roomId: documentId);
},
itemCount: (messagesCloud != null)
? messagesCloud.length
: 0,
),
);
}
}),
运行它时,出现此错误
“列表”类没有实例获取器“文档”。 收件人:_List len:2尝试调用:文档
我想念什么吗?