markAsDirty method

void markAsDirty({
  1. bool? onlySelf,
  2. bool emitEvent = true,
})

Mark the control as dirty.

This will also mark all direct ancestors as dirty to maintain the model.

Implementation

void markAsDirty({bool? onlySelf, bool emitEvent = true}) {
  onlySelf ??= false;
  _pristine = false;

  if (emitEvent) _statusChanges.add(_status!);

  var parent = _parent;
  if (parent != null && !onlySelf) {
    parent.markAsDirty(onlySelf: onlySelf);
  }
}