markAsDirty method Null safety

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

Marks the control as dirty.

A control becomes dirty when the control's value is changed through the UI.

When updateParent is false, mark only this control. When true or not supplied, marks all direct ancestors. Default is true.

When emitEvent is true or not supplied (the default), the statusChanges emit event with the latest status when the control is mark dirty. When false, no events are emitted.

Implementation

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

  if (emitEvent) {
    _statusChanges.add(_status);
  }

  if (updateParent) {
    parent?.markAsDirty(updateParent: updateParent, emitEvent: emitEvent);
  }
}