Hey I recently updated my cloud_firestore dependency from version 0.12.9+4 to 2.2.1. Now I have to make some changes in my code. I already read how to migrate the code for version 2.0.0 and changed parts of the code. But I dont get how to change it in this part:
//imbiss list from snapshot
List<Imbiss> _imbissListFromSnapshot(QuerySnapshot snapshot) {
return snapshot.docs.map((doc) {
return Imbiss(
name: doc.data["name"],
kind: doc.data["kind"],
location: doc.data["location"],
rating: doc.data["rating"],
ratingFood: doc.data["ratingFood"],
ratingLocation: doc.data["ratingLocation"],
ratingPLV: doc.data["ratingPLV"],
ratingService: doc.data["ratingService"],
date: doc.data["date"],
user: doc.data["user"],
);
}).toList();
}
The code worked perfectly fine before and now I'm getting an error for the brackets after doc.data. Android Studio tells me: The operator '[]' isn't defined for the type 'Object Function(). Do you have any clue what I have to do?
Try this:
List<Imbiss> _imbissListFromSnapshot(AsyncSnapshot<QuerySnapshot> snapshot) {
return snapshot.docs.map((doc) {
Map<String, dynamic> newDoc = doc.data();
return Imbiss(
name: newDoc["name"],
kind: newDoc["kind"],
location: newDoc["location"],
rating: newDoc["rating"],
ratingFood: newDoc["ratingFood"],
ratingLocation: newDoc["ratingLocation"],
ratingPLV: newDoc["ratingPLV"],
ratingService: newDoc["ratingService"],
date: newDoc["date"],
user: newDoc["user"],
);
}).toList();
}
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments