markAsTouched method

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

Marks the control as touched.

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), an event is emitted.

Implementation

void markAsTouched({bool updateParent = true, bool emitEvent = true}) {
  if (!_touched) {
    _touched = true;

    if (emitEvent) {
      _touchChanges.add(_touched);
    }

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