set<T> method Null safety

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

Sets type T from objectData

To set an int, call setType and an int will be saved 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().containsKey(key)) {
    if (_getObjectData()[key] == value && !forceUpdate) {
      return;
    }
    _getObjectData()[key] =
        ParseMergeTool().mergeWithPrevious(_unsavedChanges[key], value);
  } else {
    _getObjectData()[key] = value;
  }
  _unsavedChanges[key] = _getObjectData()[key];
}