Iterable<Parking> _parkingListFromSnapshot(QuerySnapshot snapshot){
return snapshot.docs.map((doc){
return Parking(
car: doc.data['car'] ?? '', //problem
name: doc.data['name'] ?? '', //problem
num: doc.data['phone'] ?? '', //problem
);
}).toList();
}
so the problem that I currently have is at the return Parking where it says that The operator '[]' isn't defined for the type 'Object? Function()'. also I already did the doc.data['car'] ?? '', as well still having the same problem
CodePudding user response:
Try changing Iterable<Parking>
to List<Parking>
.
CodePudding user response:
The data
property of a DocumentSnapshot
is a function, so you need to use ()
to invoke it:
car: doc.data()['car'] ?? ''
Alternatively you can use the get
function to get the field values.
I also recommend reading the upgrade guide for FlutterFire, as there have been significant changes.