updateValue method
void
updateValue(})
override
Sets the value of the FormGroup.
The value
argument matches the structure of the group, with control
names as keys.
When updateParent
is true or not supplied (the default) each change
affects this control and its parent, otherwise only affects to this
control.
When emitEvent
is true or not supplied (the default), both the
statusChanges and valueChanges emit events with the latest status
and value when the control is reset. When false, no events are emitted.
Example:
final form = FormGroup({
'first': FormControl(),
'last': FormControl(),
});
print(form.value); // outputs: { first: null, last: null }
form.updateValue({'first': 'John', 'last': 'Doe'});
print(form.value); // outputs: { first: 'John', last: 'Doe' }
Implementation
@override
void updateValue(
Map<String, Object?>? value, {
bool updateParent = true,
bool emitEvent = true,
}) {
value ??= {};
for (final key in _controls.keys) {
_controls[key]!.updateValue(
value[key],
updateParent: false,
emitEvent: emitEvent,
);
}
updateValueAndValidity(
updateParent: updateParent,
emitEvent: emitEvent,
);
}