FormValues.initial constructor
FormValues.initial(
- List<
SchemaComponent> components, { - Map<
String, dynamic> from = const {},
Seeds one value per named field in components: from (a record being
edited) wins when it holds the key — including an explicit null, which
is a value the user deliberately cleared — and a component's own
default fills the gap only when from has no entry at all.
Implementation
factory FormValues.initial(
List<SchemaComponent> components, {
Map<String, dynamic> from = const {},
}) {
final values = <String, Object?>{};
for (final field in _leaves(components)) {
final name = field.name!;
values[name] = _hasPath(from, name)
? _readPath(from, name)
: _defaultOf(field);
}
return FormValues._(Map.unmodifiable(values), const {});
}