array<T> method
FormArray<T>
array<T>(
- List<
Object> value, [ - List<
ValidatorFunction> validators = const [], - List<
AsyncValidatorFunction> asyncValidators = const []
Construct a new FormArray instance.
The value
must not be null.
Can optionally provide a validators
collection for the control.
Example:
Constructs an array of strings
final aliases = fb.array(['john', 'little john']);
Constructs an array of groups defined as Maps
final addressArray = fb.array([
{'city': 'Sofia'},
{'city': 'Havana'},
]);
Constructs an array of groups
final addressArray = fb.array([
fb.group({'city': 'Sofia'}),
fb.group({'city': 'Havana'}),
]);
Implementation
FormArray<T> array<T>(
List<Object> value, [
List<ValidatorFunction> validators = const [],
List<AsyncValidatorFunction> asyncValidators = const [],
]) {
return FormArray<T>(
value.map<AbstractControl<T>>((v) {
if (v is Map<String, Object>) {
return group(v) as AbstractControl<T>;
}
if (v is AbstractControl<T>) {
return v;
}
return control<T>(v as T);
}).toList(),
validators: validators,
asyncValidators: asyncValidators,
);
}