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'],
));
I'm getting an error in line 8 in "documentID: documentSnapshot.reference.documentID," the Cloud Firestore version that I'm using is 0.16.0+1.
See the API documentation for DocumentReference. The property you're looking for is called id. There is no property documentID in modern versions of the SDK.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With