FieldValue.increment constructor

const FieldValue.increment(
  1. num n
)

Returns a special value that can be used with set(), create() or update() that tells the server to increment the the field's current value by the given value.

If either current field value or the operand uses floating point precision, both values will be interpreted as floating point numbers and all arithmetic will follow IEEE 754 semantics. Otherwise, integer precision is kept and the result is capped between -2^63 and 2^63-1.

If the current field value is not of type 'number', or if the field does not yet exist, the transformation will set the field to the given value.

final documentRef = firestore.doc('col/doc');

documentRef.update({
  'counter', Firestore.FieldValue.increment(1),
}).then(() {
  return documentRef.get();
}).then((doc) {
  // doc.get('counter') was incremented
});

Implementation

const factory FieldValue.increment(num n) = _NumericIncrementTransform;