FormControl<T> class

Tracks the value and validation status of an individual form control.

Inheritance
Available Extensions

Constructors

FormControl({T? value, List<ValidatorFunction> validators = const [], List<AsyncValidatorFunction> asyncValidators = const [], int asyncValidatorsDebounceTime = 250, bool touched = false, bool disabled = false})
Creates a new FormControl instance.

Properties

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

Methods

allControlsDisabled() bool
Returns true if all children disabled, otherwise returns false.
inherited
anyControls(bool condition(AbstractControl)) bool
override
anyControlsHaveStatus(ControlStatus status) bool
Returns true if all children has the specified status, otherwise returns false.
inherited
clearAsyncValidators() → void
Empties out the async validator list.
inherited
clearValidators() → void
Empties out the sync validator list.
inherited
dispose() → void
Disposes the control
override
findControl(String path) AbstractControl
override
focus() → void
Sets focus on a ReactiveFormField widget without the interaction of the user.
override
forEachChild(void callback(AbstractControl)) → void
override
getError(String errorCode, [String? path]) Object?
Returns the error data for the control with the given errorCode in the given path.
inherited
hasError(String errorCode, [String? path]) bool
Reports whether the control with the given path has the specified errorCode.
inherited
markAllAsTouched({bool updateParent = true, bool emitEvent = true}) → void
Marks the control and all its descendant controls as touched.
inherited
markAsDirty({bool updateParent = true, bool emitEvent = true}) → void
Marks the control as dirty.
inherited
markAsDisabled({bool updateParent = true, bool emitEvent = true}) → void
Disables the control.
inherited
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.
inherited
markAsPristine({bool updateParent = true}) → void
Marks the control as pristine.
inherited
markAsTouched({bool updateParent = true, bool emitEvent = true}) → void
Marks the control as touched.
inherited
markAsUntouched({bool updateParent = true, bool emitEvent = true}) → void
Marks the control as untouched.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
patchValue(T? value, {bool updateParent = true, bool emitEvent = true}) → void
Patches the value of a control.
override
reduceValue() → T?
override
registerFocusController(FocusController focusController) → void
Registers a focus controller.
removeError(String key, {bool markAsDirty = false}) → void
Removes an error given the error key.
inherited
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.
inherited
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.
inherited
setErrors(Map<String, dynamic> errors, {bool markAsDirty = true}) → void
Sets errors on a form control when running validations manually, rather than automatically.
inherited
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.
inherited
toString() String
A string representation of this object.
inherited
unfocus({bool touched = true}) → void
Remove focus on a ReactiveFormField widget without the interaction of the user.
override
unregisterFocusController(FocusController focusController) → void
Removes the provided focusController from the control.
updatePristine({bool updateParent = true}) → void
inherited
updateTouched({bool updateParent = true}) → void
inherited
updateValue(T? value, {bool updateParent = true, bool emitEvent = true}) → void
Sets the value of the FormControl.
override
updateValueAndValidity({bool updateParent = true, bool emitEvent = true}) → void
Recalculates the value and validation status of the control.
inherited

Operators

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