FormArray<T> class Null safety

A FormArray aggregates the values of each child FormControl into an array.

It calculates its status by reducing the status values of its children. For example, if one of the controls in a FormArray is invalid, the entire array becomes invalid.

FormArray is one of the three fundamental building blocks used to define forms in Reactive Forms, along with FormControl and FormGroup.

Inheritance
Mixed in types
Available Extensions

Constructors

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

Properties

asyncValidators List<AsyncValidatorFunction>
The list of async functions that determines the validity of this control. [...]
read-only, inherited
collectionChanges Stream<List<AbstractControl<Object?>>>
Emits when a control is added or removed from collection.
read-only, inherited
controls List<AbstractControl<T>>
Gets the list of child controls.
read-only
dirty bool
A control is dirty if the user has changed the value in the UI. [...]
read-only, inherited
disabled bool
A control is disabled when its status is ControlStatus.disabled.
read-only, inherited
enabled bool
A control is enabled as long as its status is not ControlStatus.disabled.
read-only, inherited
errors Map<String, Object>
Gets all errors of the array. [...]
read-only, override
hasErrors bool
True whether the control has validation errors.
read-only, inherited
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, inherited
parent AbstractControl<Object>?
The parent control.
read / write, inherited
pending bool
A control is pending when its status is ControlStatus.pending.
read-only, inherited
pristine bool
A control is pristine if the user has not yet changed the value in the UI. [...]
read-only, inherited
rawValue List<T?>
Gets the value of the FormArray, including any disabled controls. [...]
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, inherited
statusChanged Stream<ControlStatus>
A Stream that emits the status every time it changes.
read-only, inherited
touchChanges Stream<bool>
A Stream that emits an event every time the control is touched or untouched.
read-only, inherited
touched bool
Gets if the control is touched or not. [...]
read-only, inherited
valid bool
A control is valid when its status is ControlStatus.valid.
read-only, inherited
validators List<ValidatorFunction>
The list of functions that determines the validity of this control. [...]
read-only, inherited
value List<T?>?
The current value of the control.
read / write, inherited-getter, override-setter
valueChanges Stream<List<T?>?>
A Stream that emits the value of the control every time it changes.
read-only, inherited

Methods

add(AbstractControl<T> control, {bool updateParent = true, bool emitEvent = true}) → void
Insert a new control at the end of the array. [...]
addAll(List<AbstractControl<T>> controls, {bool updateParent = true, bool emitEvent = true}) → void
Appends all controls to the end of this array. [...]
allControlsDisabled() bool
Returns true if all children disabled, otherwise returns false. [...]
override
anyControls(bool condition(AbstractControl)) bool
override
anyControlsHaveStatus(ControlStatus status) bool
Returns true if all children has the specified status, otherwise returns false. [...]
override
clear({bool emitEvent = true, bool updateParent = true}) → void
Removes all children controls from the array. [...]
clearAsyncValidators() → void
Empties out the async validator list. [...]
inherited
clearValidators() → void
Empties out the sync validator list. [...]
inherited
closeCollectionEvents() → void
Close stream that emit collection change events
inherited
contains(String name) bool
Checks if array contains a control by a given name. [...]
override
control(String name) AbstractControl
Retrieves a child control given the control's name or path. [...]
override
dispose() → void
Disposes the array.
override
emitsCollectionChanged(List<AbstractControl<Object?>> controls) → void
Notify to listeners that the collection changed. [...]
@protected, inherited
findControl(String path) AbstractControl?
override
findControlInCollection(List<String> path) AbstractControl<Object>?
Walks the path to find the matching control. [...]
inherited
focus([String name = '']) → void
Sets focus to a child control. [...]
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
insert(int index, AbstractControl<T> control, {bool updateParent = true, bool emitEvent = true}) → void
Insert a control at the given index position. [...]
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. [...]
override
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. [...]
override
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 non-existent method or property is accessed. [...]
inherited
patchValue(List<T?>? value, {bool updateParent = true, bool emitEvent = true}) → void
Patches the value of the FormArray. It accepts an array that matches the structure of the control, and does its best to match the values to the correct controls in the array. [...]
override
reduceValue() List<T?>?
Gets the values of controls as an Iterable. [...]
override
remove(AbstractControl<T> control, {bool emitEvent = true, bool updateParent = true}) → void
Removes control from the array. [...]
removeAt(int index, {bool emitEvent = true, bool updateParent = true}) AbstractControl<T>
Removes and returns the child control at the given index. [...]
removeError(String key, {bool markAsDirty = false}) → void
Removes an error given the error key. [...]
inherited
reset({List<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
resetState(List<ControlState<T>> state) → void
Resets the array, marking all controls as untouched, and setting a state for children with an initial value and disabled state. [...]
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 the focus from the UI widget without the interaction of the user. [...]
inherited
updatePristine({bool updateParent = true}) → void
@protected, inherited
updateTouched({bool updateParent = true}) → void
@protected, inherited
updateValue(List<T?>? value, {bool updateParent = true, bool emitEvent = true}) → void
Sets the value of the FormArray. [...]
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