updateModel method

void updateModel(
  1. DigitDOBAge? viewValue
)
inherited

Updates the control with the provided value.

Marks the control as dirty if the viewValue is different from the control value.

Throws ValueAccessorException if no control is registered with this value accessor.

See also registerControl.

Implementation

void updateModel(ViewDataType? viewValue) {
  if (_control == null) {
    throw ValueAccessorException(
        'No control registered. Call [ControlValueAccessor.registerControl] to register a control first.');
  }

  _viewToModelChange = true;

  final modelValue = viewToModelValue(viewValue);
  if (_control?.value != modelValue) {
    _control?.markAsDirty(emitEvent: false);
    _control?.updateValue(modelValue);
  } else {
    _viewToModelChange = false;
  }
}