set<T> method

void set<T>(
  1. String key,
  2. T value, {
  3. bool forceUpdate = true,
})

Add a key-value pair to this object.

It is recommended to name keys in camelCaseLikeThis

bool forceUpdate is always true, if unsure as to whether an item is needed or not, set to false

Implementation

void set<T>(String key, T value, {bool forceUpdate = true}) {
  if (_getObjectData()[key] == value && !forceUpdate) {
    return;
  }

  _getObjectData()[key] = _ParseOperation.maybeMergeWithPrevious<T>(
    newValue: value,
    previousValue: _getObjectData()[key],
    parent: this as ParseObject,
    key: key,
  );

  _unsavedChanges[key] = _getObjectData()[key];
}