I want to create/update a set of data in the cloud firestore in that is stored in a nested array method.
I want to define the nested array to be in a Map<String, dynamic>
method like this.
CodePudding user response:
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)))