Flutter Firestore QuerySnapshot没有getter'document的实例 [英] Flutter Firestore QuerySnapshot has no instance of getter 'document
本文介绍了Flutter Firestore QuerySnapshot没有getter'document的实例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用它从Firestore数据库中获取消息列表,但是,这给了我一个错误:
I'm using this to get a list of messages from the firestore database, however, it's giving me an error:
颤振:构建时引发了以下NoSuchMethodError: flutter:类"QuerySnapshot"没有实例获取器"document". 颤动:接收器:'QuerySnapshot'的实例 颤抖:尝试通话:文档
flutter: The following NoSuchMethodError was thrown building: flutter: Class 'QuerySnapshot' has no instance getter 'document'. flutter: Receiver: Instance of 'QuerySnapshot' flutter: Tried calling: document
我正在使用的代码是:
StreamBuilder(
stream: Firestore.instance
.collection('messages')
.document(groupId)
.collection(groupId)
.orderBy('timestamp', descending: true)
.snapshots(),
builder: (BuildContext context, AsyncSnapshot snapshot) {
if (!snapshot.hasData) {
return Center(
child: CircularProgressIndicator(),
);
} else {
listMessage = snapshot.data.documents;
return ListView.builder(
padding: EdgeInsets.all(10.0),
itemBuilder: (context, index) =>
buildItem(index, snapshot.data.document[index]),
itemCount: snapshot.data.documents.length,
reverse: true,
controller: scrollController,
);
}
},
),
我是Firestore的新手,noSQL谁能在这里提供帮助?
I'm new to Firestore and noSQL can anyone help here please?
推荐答案
我遇到了同样的问题.这是一个错字.
I had the same issue. It was a typo.
snapshot.data.document[index]
应为:
snapshot.data.documents[index]
这篇关于Flutter Firestore QuerySnapshot没有getter'document的实例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文