updateValue method Null safety

  1. @override
void updateValue(
  1. Map<String, Object?>? value,
  2. {bool updateParent = true,
  3. bool emitEvent = true}

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.


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' }


void updateValue(
  Map<String, Object?>? value, {
  bool updateParent = true,
  bool emitEvent = true,
}) {
  value ??= {};

  for (final key in _controls.keys) {
      updateParent: false,
      emitEvent: emitEvent,

    updateParent: updateParent,
    emitEvent: emitEvent,