I have initial data which works fine.
var data = {field1: FieldValue.increment(1)};
And it is also fine when I add another field to the data.
data.addAll({field2: FieldValue.increment(1)});
But if I set the value to 0, it won't allow me to.
data.addAll({field3: 0});
It will give an error of: The element type 'int' can't be assigned to the map value type 'FieldValue'.
I tried doing this but still, have the same issue.
data[field3] = 0;
How will I set the field3
to a specific value?
Note: This is the full code.
DocumentReference<Map<String, dynamic>> ref = db.collection('MyCollect').doc(uid);
var data = {field1: FieldValue.increment(1)};
data.addAll({field2: FieldValue.increment(1)});
data.addAll({field3: 0});
ref.set(data, SetOptions(merge: true));