sahil patel
sahil patel

Reputation: 54

I can't change firebase field in custom action in flutter flow

QuerySnapshot querySnapshot = await FirebaseFirestore.instance
        .collection('collection-name')
        .where("users", arrayContains: userRef)
        .get();
  1. I get data from firebase with above script and store in querySnapshot.
    List<CircleRecord> circles = [];

    querySnapshot.docs.forEach((DocumentSnapshot doc) {
      Map<String, dynamic> newData = doc.data() as Map<String, dynamic>;
      newData['fieldName'] = 'Hello';
      CircleRecord record = CircleRecord.fromMap(newData);
      circles.add(record);
    });
  1. I apply forEach loop on querySnapshot to get specific data object and store in new data to change specific field. 'CircleRecord' is getting from firebase and it's a return list of documents. I change 'newData['fieldName']' this field name and convert whole data to circleRecord object or class and adding those data 'circles' list.

error screenshot

I need to change specific field value and store whole data in circle list with type of circleRecord document.

Upvotes: 1

Views: 211

Answers (1)

Frank van Puffelen
Frank van Puffelen

Reputation: 599876

The CircleRecord class in your code and error message is not part of any Firebase API. Specifically it is not something that is defined in the reference docs of the Firestore package.

Rather CircleRecord it is a custom class that your have to define to represent the data from a document in Firestore. If you've never created such a class before, these search results show some good starting points: https://www.google.com/search?q=how+to+define+pojo+class+for+Firestore+in+Flutter

Upvotes: 0

Related Questions