FieldValue.increment constructor

FieldValue.increment(
  1. num value
)

Adds value to the number in the field; use a negative value to subtract.

If both the current value and value are integers, the result is an integer, clamped to the range of a 64-bit signed integer instead of overflowing. If either is a double, the result is a double (IEEE 754). If the field is not a number (or does not exist), it is set to value.

await firestore.doc('counters/visits').update(<String, Object?>{
  'value': FieldValue.increment(1),
});

When the answer to a commit is lost and the client sends the write again, the increment can be applied twice; the JS and Android SDKs have the same exposure.

Implementation

factory FieldValue.increment(num value) {
  return _NumericIncrementFieldValue(value);
}