getRawValue method

  1. @override
Map<String, dynamic> getRawValue({
  1. bool flatten = true,
})
override

Builds a raw value map for all controls in this group. When flatten is enabled, values from nested groups are flattened into the parent map; otherwise, the nested structure is preserved.

Implementation

@override
Map<String, dynamic> getRawValue({bool flatten = true}) {
  final rawValue = <String, dynamic>{};
  for (var entry in controls.entries) {
    if(entry.value is FormGroup){
      final group = entry.value as FormGroup;
      if(!flatten){
        rawValue[entry.key] = group.getRawValue();
        continue;
      }
      rawValue.addAll(group.getRawValue());
      continue;
    }
    rawValue[entry.key] = entry.value.getRawValue();
  }
  return rawValue;
}