Skip to content

Commit

Permalink
Add value property to BooleanMetaDataField to set initial state of ch…
Browse files Browse the repository at this point in the history
…eckbox. (#120)
  • Loading branch information
bcorman authored Oct 11, 2024
1 parent 254d09a commit 4ef07d8
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/src/components/supa_email_auth.dart
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ class MetaDataField {
/// must check the checkbox in order to sign up.
/// {@endtemplate}
class BooleanMetaDataField extends MetaDataField {
/// Whether the checkbox is initially checked.
final bool value;

/// Rich text spans for the label. If provided, this will be used instead of [label].
final List<InlineSpan>? richLabelSpans;

Expand All @@ -110,6 +113,7 @@ class BooleanMetaDataField extends MetaDataField {
/// {@macro boolean_metadata_field}
BooleanMetaDataField({
String? label,
this.value = false,
this.richLabelSpans,
this.checkboxSemanticLabel,
this.isRequired = false,
Expand Down Expand Up @@ -256,7 +260,9 @@ class _SupaEmailAuthState extends State<SupaEmailAuth> {
_metadataControllers = Map.fromEntries((widget.metadataFields ?? []).map(
(metadataField) => MapEntry(
metadataField.key,
metadataField is BooleanMetaDataField ? false : TextEditingController(),
metadataField is BooleanMetaDataField
? metadataField.value
: TextEditingController(),
),
));
}
Expand Down

0 comments on commit 4ef07d8

Please sign in to comment.