AbstractControl<T> class Null safety

This is the base class for FormGroup, FormArray and FormControl.

It provides some of the shared behavior that all controls and groups have, like running validators, calculating status, and resetting state.

It also defines the properties that are shared between all sub-classes, like value and valid.

It shouldn't be instantiated directly.

Implementers
Available Extensions

Constructors

AbstractControl({List<ValidatorFunction> validators = const [], List<AsyncValidatorFunction> asyncValidators = const [], int asyncValidatorsDebounceTime = 250, bool disabled = false, bool touched = false})
Constructor of the AbstractControl.

Properties

asyncValidators List<AsyncValidatorFunction>
The list of async functions that determines the validity of this control. [...]
read-only
dirty bool
A control is dirty if the user has changed the value in the UI. [...]
read-only
disabled bool
A control is disabled when its status is ControlStatus.disabled.
read-only
enabled bool
A control is enabled as long as its status is not ControlStatus.disabled.
read-only
errors Map<String, Object>
An object containing any errors generated by failing validation, or empty Map if there are no errors.
read-only
hasErrors bool
True whether the control has validation errors.
read-only
hashCode int
The hash code for this object. [...]
read-only, inherited
invalid bool
A control is invalid when its status is ControlStatus.invalid.
read-only
parent AbstractControl<Object>?
The parent control.
read / write
pending bool
A control is pending when its status is ControlStatus.pending.
read-only
pristine bool
A control is pristine if the user has not yet changed the value in the UI. [...]
read-only
runtimeType Type
A representation of the runtime type of the object.
read-only, inherited
status ControlStatus
The validation status of the control. [...]
read-only
statusChanged Stream<ControlStatus>
A Stream that emits the status every time it changes.
read-only
touchChanges Stream<bool>
A Stream that emits an event every time the control is touched or untouched.
read-only
touched bool
Gets if the control is touched or not. [...]
read-only
valid bool
A control is valid when its status is ControlStatus.valid.
read-only
validators List<ValidatorFunction>
The list of functions that determines the validity of this control. [...]
read-only
value ↔ T?
The current value of the control.
read / write
valueChanges Stream<T?>
A Stream that emits the value of the control every time it changes.
read-only

Methods

allControlsDisabled() bool
Returns true if all children disabled, otherwise returns false.
anyControls(bool condition(AbstractControl)) bool
anyControlsHaveStatus(ControlStatus status) bool
Returns true if all children has the specified status, otherwise returns false.
clearAsyncValidators() → void
Empties out the async validator list. [...]
clearValidators() → void
Empties out the sync validator list. [...]
dispose() → void
Disposes the control
findControl(String path) AbstractControl?
focus() → void
forEachChild(void callback(AbstractControl)) → void
getError(String errorCode, [String? path]) Object?
Returns the error data for the control with the given errorCode in the given path. [...]
hasError(String errorCode, [String? path]) bool
Reports whether the control with the given path has the specified errorCode. [...]
markAllAsTouched({bool updateParent = true, bool emitEvent = true}) → void
Marks the control and all its descendant controls as touched. [...]
markAsDirty({bool updateParent = true, bool emitEvent = true}) → void
Marks the control as dirty. [...]
markAsDisabled({bool updateParent = true, bool emitEvent = true}) → void
Disables the control. [...]
markAsEnabled({bool updateParent = true, bool emitEvent = true}) → void
Enables the control. This means the control is included in validation checks and the aggregate value of its parent. Its status recalculates based on its value and its validators. [...]
markAsPristine({bool updateParent = true}) → void
Marks the control as pristine. [...]
markAsTouched({bool updateParent = true, bool emitEvent = true}) → void
Marks the control as touched. [...]
markAsUntouched({bool updateParent = true, bool emitEvent = true}) → void
Marks the control as untouched. [...]
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed. [...]
inherited
patchValue(T? value, {bool updateParent = true, bool emitEvent = true}) → void
Patches the value of the control. [...]
reduceValue() → T?
removeError(String key, {bool markAsDirty = false}) → void
Removes an error given the error key. [...]
reset({T? value, bool updateParent = true, bool emitEvent = true, bool removeFocus = false, bool? disabled}) → void
Resets the control, marking it as untouched, pristine and setting the value to null. [...]
setAsyncValidators(List<AsyncValidatorFunction> validators, {bool autoValidate = false, bool updateParent = true, bool emitEvent = true}) → void
Sets the async validators that are active on this control. Calling this overwrites any existing async validators. [...]
setErrors(Map<String, dynamic> errors, {bool markAsDirty = true}) → void
Sets errors on a form control when running validations manually, rather than automatically. [...]
setValidators(List<ValidatorFunction> validators, {bool autoValidate = false, bool updateParent = true, bool emitEvent = true}) → void
Sets the synchronous validators that are active on this control. Calling this overwrites any existing sync validators. [...]
toString() String
A string representation of this object. [...]
inherited
unfocus({bool touched = true}) → void
Remove the focus from the UI widget without the interaction of the user. [...]
updatePristine({bool updateParent = true}) → void
updateTouched({bool updateParent = true}) → void
updateValue(T? value, {bool updateParent = true, bool emitEvent = true}) → void
Sets the value of the control. [...]
updateValueAndValidity({bool updateParent = true, bool emitEvent = true}) → void
Recalculates the value and validation status of the control. [...]

Operators

operator ==(Object other) bool
The equality operator. [...]
inherited