reduceValue method Null safety

  1. @override
Map<String, Object?> reduceValue()
override

Reduce the value of the group is a key-value pair for each control in the group.

Example:

final form = FormGroup({
  'name': FormControl(defaultValue: 'John Doe'),
  'email': FormControl(defaultValue: 'johndoe@email.com'),
});

print(form.value);
{ "name": "John Doe", "email": "johndoe@email.com" }

This method is for internal use only.

Implementation

@override
Map<String, Object?> reduceValue() {
  final map = <String, Object?>{};
  _controls.forEach((key, control) {
    if (control.enabled || disabled) {
      map[key] = control.value;
    }
  });

  return map;
}