markAsDisabled method

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

Disables the control.

This means the control is exempt from validation checks and excluded from the aggregate value of any parent. Its status is DISABLED.

If the control has children, all children are also disabled.

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

Implementation

void markAsDisabled({bool updateParent = true, bool emitEvent = true}) {
  if (disabled) {
    return;
  }

  _errors.clear();
  _status = ControlStatus.disabled;
  if (emitEvent) {
    _statusChanges.add(_status);
  }
  _updateAncestors(updateParent);
}