I'm using this to get a list of messages from the firestore database, however, it's giving me an error:
flutter: The following NoSuchMethodError was thrown building:
flutter: Class 'QuerySnapshot' has no instance getter 'document'.
flutter: Receiver: Instance of 'QuerySnapshot'
flutter: Tried calling: document
The code that I'm using is :
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,
);
}
},
),
I'm new to Firestore and noSQL can anyone help here please?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…