CollectionReference itemsReference =
FirebaseFirestore.instance.collection('items');
itemsReference.snapshots().forEach((snapshot) {
snapshot.docs.forEach((documentSnapshot) {
products.add(new Product(
name: documentSnapshot.data()['name'],
price: double.parse("${documentSnapshot.data()['price']}"),
documentId: documentSnapshot.reference.documentID,// The getter 'documentID' isn't defined for the type 'DocumentReference'.
description: documentSnapshot.data()['description'],
image: documentSnapshot.data()['image'],
imageCount: documentSnapshot.data()['image_count'],
sellerEmail: documentSnapshot.data()['seller'],
category: documentSnapshot.data()['category'],
location: documentSnapshot.data()['location'],
verified: documentSnapshot.data()['verified'],
));
我在“documentID:documentSnapshot.reference.documentID”的第 8 行收到错误,我使用的 Cloud Firestore 版本是 0.16.0+1。