Skip to content

Commit f16cc3b

Browse files
committed
Component Instances #44
1 parent 1ca7a20 commit f16cc3b

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

lib/src/api/field_access.dart

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,12 @@ sealed class FieldAccess<T extends Object?> {
5858
/// Sets the value of the field.
5959
void setValue(Object? value);
6060

61-
final DefaultFieldValueCallback<T>? _defaultValue;
61+
/// The default value of the field.
62+
final DefaultFieldValueCallback<T>? defaultValue;
6263

6364
/// Whether the field requires layout when changed.
6465
final bool requiresLayout;
6566

66-
/// The default value of the field.
67-
DefaultFieldValueCallback<T>? get getDefaultValue => _defaultValue;
68-
6967
/// The serialized value of the field.
7068
Object? serialize(T? obj) => obj;
7169

@@ -85,7 +83,7 @@ sealed class FieldAccess<T extends Object?> {
8583
'label': label,
8684
'description': description,
8785
'value': serialize(getValue()),
88-
if (getDefaultValue case DefaultFieldValueCallback<T> defaultValue)
86+
if (defaultValue case DefaultFieldValueCallback<T> defaultValue)
8987
'default': serialize(defaultValue()),
9088
if (supplementarySchema case Map<String, dynamic> supplementary)
9189
...supplementary
@@ -97,9 +95,9 @@ sealed class FieldAccess<T extends Object?> {
9795
this.description,
9896
this.getValue,
9997
this.setter, {
100-
DefaultFieldValueCallback<T>? defaultValue,
98+
this.defaultValue,
10199
this.requiresLayout = false,
102-
}) : _defaultValue = defaultValue;
100+
});
103101
}
104102

105103
/// A field accessor for a [String] field.
@@ -449,7 +447,7 @@ final class VariantAccess extends FieldAccess<String> {
449447
@override
450448
void setValue(Object? value) {
451449
if (value case String? value) {
452-
setter(value ?? getDefaultValue!());
450+
setter(value ?? defaultValue!());
453451
}
454452
}
455453
}

0 commit comments

Comments
 (0)