reset method

void reset({
  1. T? value,
  2. bool? isDisabled,
  3. bool? updateParent,
  4. bool? emitEvent,
})

Resets the form control.

This means by default:

  • it is marked as pristine
  • it is marked as untouched
  • value is set to null

You can also reset to a specific form state by passing through a standalone value or a disabled state. We allow setting value and disabled here because these are the only two properties that cannot be calculated.

Implementation

void reset(
    {T? value, bool? isDisabled, bool? updateParent, bool? emitEvent}) {
  updateParent ??= true;
  emitEvent ??= true;
  updateValue(value, onlySelf: !updateParent, emitEvent: emitEvent);
  if (isDisabled != null) {
    isDisabled
        ? markAsDisabled(updateParent: updateParent, emitEvent: emitEvent)
        : markAsEnabled(updateParent: updateParent, emitEvent: emitEvent);
  }
  markAsPristine(updateParent: updateParent);
  markAsUntouched(updateParent: updateParent);
}