Skip to content

Commit 1ceddbb

Browse files
committed
Add value property to BooleanMetaDataField to set initial state of checkbox.
1 parent 726f55e commit 1ceddbb

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

lib/src/components/supa_email_auth.dart

Lines changed: 7 additions & 1 deletion
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,
@@ -249,7 +253,9 @@ class _SupaEmailAuthState extends State<SupaEmailAuth> {
249253
_metadataControllers = Map.fromEntries((widget.metadataFields ?? []).map(
250254
(metadataField) => MapEntry(
251255
metadataField.key,
252-
metadataField is BooleanMetaDataField ? false : TextEditingController(),
256+
metadataField is BooleanMetaDataField
257+
? metadataField.value
258+
: TextEditingController(),
253259
),
254260
));
255261
}

0 commit comments

Comments
 (0)