2

I want to create/update a set of data in the cloud firestore in that is stored in a nested array method.

enter image description here I want to define the nested array to be in a Map<String, dynamic> method like this.

1

1 Answer 1

2

First, you have to create instance of categories model then change the value according to your requirement

for ex:

 Categories c =  categories; // here assign your exiting data of categories
     c.copyWith(flavor : ["hello","world"]);

          await FirebaseFirestore.instance
          .collection('user')
          .doc(FirebaseAuth.instance.currentUser?.uid)
          .collection('todos')
          .doc(map["collectionId"])
          .update(FieldValue.arrayUnion(c)))
Sign up to request clarification or add additional context in comments.

2 Comments

Thanks, can you give me an example of how to write a copyWith function
stackoverflow.com/questions/62372580/… @NitinGopal please refer it

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.