Skip to content

Commit 4ef07d8

Browse files
authored
Add value property to BooleanMetaDataField to set initial state of checkbox. (#120)
1 parent 254d09a commit 4ef07d8

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

lib/src/components/supa_email_auth.dart

+7-1
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,9 @@ class MetaDataField {
9090
/// must check the checkbox in order to sign up.
9191
/// {@endtemplate}
9292
class BooleanMetaDataField extends MetaDataField {
93+
/// Whether the checkbox is initially checked.
94+
final bool value;
95+
9396
/// Rich text spans for the label. If provided, this will be used instead of [label].
9497
final List<InlineSpan>? richLabelSpans;
9598

@@ -110,6 +113,7 @@ class BooleanMetaDataField extends MetaDataField {
110113
/// {@macro boolean_metadata_field}
111114
BooleanMetaDataField({
112115
String? label,
116+
this.value = false,
113117
this.richLabelSpans,
114118
this.checkboxSemanticLabel,
115119
this.isRequired = false,
@@ -256,7 +260,9 @@ class _SupaEmailAuthState extends State<SupaEmailAuth> {
256260
_metadataControllers = Map.fromEntries((widget.metadataFields ?? []).map(
257261
(metadataField) => MapEntry(
258262
metadataField.key,
259-
metadataField is BooleanMetaDataField ? false : TextEditingController(),
263+
metadataField is BooleanMetaDataField
264+
? metadataField.value
265+
: TextEditingController(),
260266
),
261267
));
262268
}

0 commit comments

Comments
 (0)