Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add value property to BooleanMetaDataField to set initial state of checkbox #120

Merged
merged 1 commit into from
Oct 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -249,7 +253,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
Loading