I'm trying to add an object to an array in Firestore. My code is
Future signUpForClass(String docId, Member member) async {
await _fireStoreInstance.collection("collection_name").doc(docId).update({
"signedUpMembers": FieldValue.arrayUnion([member])
});
}
but I get an error saying: Invalid argument: Instance of 'Member'
When I check on the empty array in Firestore it seems like the type of the array is a String and I am able to use a string argument, i.e. member.name, and then I can add/remove from the array. However, when I create the document with the "signedUpMembers" array, I pass the array an empty list of Members, i.e. "signedUpMembers": <Member>[]
What am I doing wrong? I've tried a bunch of different syntax for this but I haven't been able to add the whole object to the array, only strings.