setRawValue method
Recursively applies a raw value map to this group and its nested groups.
raw must be a Map<String, dynamic> where each key matches a control name.
- For nested FormGroup controls, the same
rawmap is forwarded so the group can pick its own keys. - For non-group controls, only the value for the corresponding key is applied.
Notification behavior:
- Child controls are updated with
notify: falseto avoid cascading notifications. - When
notifyis true, this FormGroup notifies its listeners after each control update. If you need to notify all controls after a bulk update, prefer callingrefreshAll().
Implementation
@override
void setRawValue(Object? raw, {bool notify = true}) {
if (raw == null) return;
if (raw is! Map<String, dynamic>) {
throw ArgumentError(
'FormGroup.setRawValue espera Map<String, dynamic>. Recebido: ${raw.runtimeType}',
);
}
for (final entry in controls.entries) {
if(entry.value is FormGroup) {
final group = entry.value as FormGroup;
group.setRawValue(raw);
continue;
}
entry.value.setRawValue(raw[entry.key], notify: false);
if(notify) notifyListeners();
}
}