How Do I Add Equal Elements To An Array In Firestore In Flutter?

I just figured out that in Flutter

List<int> values = [1,2,3,1,2,3];
Firestore.instance.path.updateData({"values": FieldValue.arrayUnion(values)});

results in the Firestore Array

(Firestore Array) [1,2,3]

Obviously the values are somehow mapped, removing duplicate values, although I can manually add duplicate values online in the Firebase panel (the datatype is called array respectively).

Is there a way to bypass this behaviour or is this a bug?



According to the documentation here, array union will only add the elements that are not present. Because you're using a Firestore function intended to only add new unique values, it will behave that way without being bypassed. You can certainly bypass this function, though, but not without first calling the document, retrieving the array, and appending it before updating it to Firestore.