How to fix error with new Firestore version?

Yoqora

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?

krumpli

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.

edited at
0

Comments

0 comments
Login to comment

Related

Multiple command produce gRPCCertificates.bundle error in new Firestore Version

How to i fix a firestore error complaining about order by on equality filter

How to fix this TSLint (Object is possibly 'undefined') error for firestore

How to fix error "Ambiguous use of 'increment'" on iOS Firestore increment()

How can I fix Firebase/firestore error in React native?

How can I fix my firestore database setup error?

How can I fix this Firestore error: FieldPath.documentId is not a function

Popmotion carousel fix for new version

How to fix error “Expected version spec in …” using pip install on Windows?

How to fix FloatingActionButton inflate error in androidx for API Version 23?

How to force renderscript version to fix lint error: GradleCompatible

How to fix an error while upgrading the targetSdkVersion from version 25 to 27?

How to fix the error "Windows SDK version 8.1" was not found?

How to fix install error "Could not find a version that satisfies the requirement pyplot"?

How to fix SWIFT_VERSION error on PhoneGap Build

How to fix "ERROR: Could not find a version that matches install"?

How to fix: "EPROTO" Error after upgrading Node's version

How to fix this error in console when I create a new laravel project?

How to fix new line error when parse xml

How to fix error used by new Place SDK for android

How to fix “Bad minute” error while installing a new crontab

How to fix throw new Error('Expected the listener to be a function.');

Error : Please fix the version conflict?

Error: Please fix the version conflict

How to force Eclipse to use specific version of NodeJS to fix error "Node.js version could not be determined"?

In new React version, how to fix TypeError: styled_components__WEBPACK_IMPORTED_MODULE_3__.default.dev?

How to fix "Error in .local(conn, statement, ...) : could not run statement: The used command is not allowed with this MySQL version" error in R?

Error when trying to call setData(from: ) in the Cloud Firestore ios API. How can i fix it?

How to avoid modifying Firebase Firestore data when working on new version of a app