【发布时间】:2021-11-02 22:16:04
【问题描述】:
试图获取我的流快照长度,但由于某种原因 .docs 无法正常工作。它说文档不能在对象上调用,但我不明白为什么当它应该是流时它会将我的 streamSnapshot 读取为对象。
return Scaffold(
body: StreamBuilder(
stream: FirebaseFirestore.instance
.collection('chats/khgvkhvfkftkh/messages')
.snapshots(),
builder: (ctx, streamSnapshot) {
if (streamSnapshot.connectionState == ConnectionState.waiting) {
return Center(
child: CircularProgressIndicator(),
);
}
final documents =
streamSnapshot.data.docs.length;
return ListView.builder(
itemCount: documents.length, //does not work due to error in declaration of documents
itemBuilder: (ctx, index) => Container(
【问题讨论】: