FieldValue.arrayUnion constructor
Adds each of elements to the end of the array in the field, unless the
array already contains an equal value.
If the field is not an array (or does not exist), it is set to an array
of exactly elements. Values are compared as the backend compares them:
the integer 1 and the double 1.0 are equal (the JS SDK compares them
strictly). elements cannot contain other FieldValues or arrays.
await firestore.doc('cities/SF').update(<String, Object?>{
'regions': FieldValue.arrayUnion(<Object?>['west_coast', 'norcal']),
});
Implementation
factory FieldValue.arrayUnion(Iterable<Object?> elements) {
return _ArrayUnionFieldValue._(elements.toList());
}