Skip to content

Commit 035b438

Browse files
Copilotmaurovanetti
andcommitted
Apply dart format to code
Co-authored-by: maurovanetti <402070+maurovanetti@users.noreply.github.com>
1 parent 0c36bc5 commit 035b438

File tree

7 files changed

+350
-342
lines changed

7 files changed

+350
-342
lines changed

lib/src/components/supa_email_auth.dart

Lines changed: 127 additions & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,11 @@ class BooleanMetaDataField extends MetaDataField {
119119
this.isRequired = false,
120120
this.checkboxPosition = ListTileControlAffinity.platform,
121121
required super.key,
122-
}) : assert(label != null || richLabelSpans != null,
123-
'Either label or richLabelSpans must be provided'),
124-
super(label: label ?? '');
122+
}) : assert(
123+
label != null || richLabelSpans != null,
124+
'Either label or richLabelSpans must be provided',
125+
),
126+
super(label: label ?? '');
125127

126128
Widget getLabelWidget(BuildContext context) {
127129
// This matches the default style of [TextField], to match the other fields
@@ -132,10 +134,7 @@ class BooleanMetaDataField extends MetaDataField {
132134
: Theme.of(context).textTheme.titleMedium;
133135
return richLabelSpans != null
134136
? RichText(
135-
text: TextSpan(
136-
style: defaultStyle,
137-
children: richLabelSpans,
138-
),
137+
text: TextSpan(style: defaultStyle, children: richLabelSpans),
139138
)
140139
: Text(label, style: defaultStyle);
141140
}
@@ -286,14 +285,16 @@ class _SupaEmailAuthState extends State<SupaEmailAuth> {
286285
_emailController.text = widget.prefilledEmail ?? '';
287286
_passwordController.text = widget.prefilledPassword ?? '';
288287
_isSigningIn = widget.isInitiallySigningIn;
289-
_metadataControllers = Map.fromEntries((widget.metadataFields ?? []).map(
290-
(metadataField) => MapEntry(
291-
metadataField.key,
292-
metadataField is BooleanMetaDataField
293-
? metadataField.value
294-
: TextEditingController(),
288+
_metadataControllers = Map.fromEntries(
289+
(widget.metadataFields ?? []).map(
290+
(metadataField) => MapEntry(
291+
metadataField.key,
292+
metadataField is BooleanMetaDataField
293+
? metadataField.value
294+
: TextEditingController(),
295+
),
295296
),
296-
));
297+
);
297298
}
298299

299300
@override
@@ -357,7 +358,8 @@ class _SupaEmailAuthState extends State<SupaEmailAuth> {
357358
textInputAction: widget.metadataFields != null && !_isSigningIn
358359
? TextInputAction.next
359360
: TextInputAction.done,
360-
validator: widget.passwordValidator ??
361+
validator:
362+
widget.passwordValidator ??
361363
(value) {
362364
if (value == null || value.isEmpty || value.length < 6) {
363365
return localization.passwordLengthError;
@@ -397,91 +399,98 @@ class _SupaEmailAuthState extends State<SupaEmailAuth> {
397399
spacer(16),
398400
if (widget.metadataFields != null && !_isSigningIn)
399401
...widget.metadataFields!
400-
.map((metadataField) => [
401-
// Render a Checkbox that displays an error message
402-
// beneath it if the field is required and the user
403-
// hasn't checked it when submitting the form.
404-
if (metadataField is BooleanMetaDataField)
405-
FormField<bool>(
406-
validator: metadataField.isRequired
407-
? (bool? value) {
408-
if (value != true) {
409-
return localization.requiredFieldError;
410-
}
411-
return null;
402+
.map(
403+
(metadataField) => [
404+
// Render a Checkbox that displays an error message
405+
// beneath it if the field is required and the user
406+
// hasn't checked it when submitting the form.
407+
if (metadataField is BooleanMetaDataField)
408+
FormField<bool>(
409+
validator: metadataField.isRequired
410+
? (bool? value) {
411+
if (value != true) {
412+
return localization.requiredFieldError;
412413
}
413-
: null,
414-
builder: (FormFieldState<bool> field) {
415-
final theme = Theme.of(context);
416-
417-
return Column(
418-
crossAxisAlignment: CrossAxisAlignment.start,
419-
children: [
420-
CheckboxListTile(
421-
title:
422-
metadataField.getLabelWidget(context),
423-
value: _metadataControllers[
424-
metadataField.key] as bool,
425-
onChanged: (bool? value) {
426-
setState(() {
427-
_metadataControllers[metadataField
428-
.key] = value ?? false;
429-
});
430-
field.didChange(value);
431-
},
432-
checkboxSemanticLabel:
433-
metadataField.checkboxSemanticLabel,
434-
controlAffinity:
435-
metadataField.checkboxPosition,
436-
contentPadding:
437-
const EdgeInsets.symmetric(
438-
horizontal: 4.0),
414+
return null;
415+
}
416+
: null,
417+
builder: (FormFieldState<bool> field) {
418+
final theme = Theme.of(context);
419+
420+
return Column(
421+
crossAxisAlignment: CrossAxisAlignment.start,
422+
children: [
423+
CheckboxListTile(
424+
title: metadataField.getLabelWidget(
425+
context,
439426
),
440-
if (field.hasError)
441-
Padding(
442-
padding: const EdgeInsets.only(
443-
left: 16, top: 4),
444-
child: Text(
445-
field.errorText!,
446-
style: theme.textTheme.labelSmall
447-
?.copyWith(
448-
color: theme.colorScheme.error,
449-
),
450-
),
427+
value:
428+
_metadataControllers[metadataField.key]
429+
as bool,
430+
onChanged: (bool? value) {
431+
setState(() {
432+
_metadataControllers[metadataField
433+
.key] =
434+
value ?? false;
435+
});
436+
field.didChange(value);
437+
},
438+
checkboxSemanticLabel:
439+
metadataField.checkboxSemanticLabel,
440+
controlAffinity:
441+
metadataField.checkboxPosition,
442+
contentPadding: const EdgeInsets.symmetric(
443+
horizontal: 4.0,
444+
),
445+
),
446+
if (field.hasError)
447+
Padding(
448+
padding: const EdgeInsets.only(
449+
left: 16,
450+
top: 4,
451+
),
452+
child: Text(
453+
field.errorText!,
454+
style: theme.textTheme.labelSmall
455+
?.copyWith(
456+
color: theme.colorScheme.error,
457+
),
451458
),
452-
],
453-
);
454-
},
455-
)
456-
else
457-
// Otherwise render a normal TextFormField matching
458-
// the style of the other fields in the form.
459-
TextFormField(
460-
controller:
461-
_metadataControllers[metadataField.key]
462-
as TextEditingController,
463-
textInputAction:
464-
widget.metadataFields!.last == metadataField
465-
? TextInputAction.done
466-
: TextInputAction.next,
467-
decoration: InputDecoration(
468-
label: Text(metadataField.label),
469-
prefixIcon: metadataField.prefixIcon,
470-
),
471-
validator: metadataField.validator,
472-
autovalidateMode:
473-
AutovalidateMode.onUserInteraction,
474-
onFieldSubmitted: (_) {
475-
if (metadataField !=
476-
widget.metadataFields!.last) {
477-
FocusScope.of(context).nextFocus();
478-
} else if (widget.enableAutomaticFormSubmission) {
479-
_signInSignUp();
480-
}
481-
},
459+
),
460+
],
461+
);
462+
},
463+
)
464+
else
465+
// Otherwise render a normal TextFormField matching
466+
// the style of the other fields in the form.
467+
TextFormField(
468+
controller:
469+
_metadataControllers[metadataField.key]
470+
as TextEditingController,
471+
textInputAction:
472+
widget.metadataFields!.last == metadataField
473+
? TextInputAction.done
474+
: TextInputAction.next,
475+
decoration: InputDecoration(
476+
label: Text(metadataField.label),
477+
prefixIcon: metadataField.prefixIcon,
482478
),
483-
spacer(16),
484-
])
479+
validator: metadataField.validator,
480+
autovalidateMode:
481+
AutovalidateMode.onUserInteraction,
482+
onFieldSubmitted: (_) {
483+
if (metadataField !=
484+
widget.metadataFields!.last) {
485+
FocusScope.of(context).nextFocus();
486+
} else if (widget.enableAutomaticFormSubmission) {
487+
_signInSignUp();
488+
}
489+
},
490+
),
491+
spacer(16),
492+
],
493+
)
485494
.expand((element) => element),
486495
ElevatedButton(
487496
onPressed: _signInSignUp,
@@ -494,9 +503,11 @@ class _SupaEmailAuthState extends State<SupaEmailAuth> {
494503
strokeWidth: 1.5,
495504
),
496505
)
497-
: Text(_isSigningIn
498-
? localization.signIn
499-
: localization.signUp),
506+
: Text(
507+
_isSigningIn
508+
? localization.signIn
509+
: localization.signUp,
510+
),
500511
),
501512
spacer(16),
502513
if (_isSigningIn) ...[
@@ -520,9 +531,11 @@ class _SupaEmailAuthState extends State<SupaEmailAuth> {
520531
widget.onToggleSignIn?.call(_isSigningIn);
521532
widget.onToggleRecoverPassword?.call(_isRecoveringPassword);
522533
},
523-
child: Text(_isSigningIn
524-
? localization.dontHaveAccount
525-
: localization.haveAccount),
534+
child: Text(
535+
_isSigningIn
536+
? localization.dontHaveAccount
537+
: localization.haveAccount,
538+
),
526539
),
527540
],
528541
if (_isSigningIn && _isRecoveringPassword) ...[
@@ -596,7 +609,8 @@ class _SupaEmailAuthState extends State<SupaEmailAuth> {
596609
} catch (error) {
597610
if (widget.onError == null && mounted) {
598611
context.showErrorSnackBar(
599-
'${widget.localization.unexpectedError}: $error');
612+
'${widget.localization.unexpectedError}: $error',
613+
);
600614
} else {
601615
widget.onError?.call(error);
602616
}
@@ -657,10 +671,15 @@ class _SupaEmailAuthState extends State<SupaEmailAuth> {
657671

658672
/// Resolve the user_metadata coming from the metadataFields
659673
Map<String, dynamic> _resolveMetadataFieldsData() {
660-
return Map.fromEntries(_metadataControllers.entries.map((entry) => MapEntry(
661-
entry.key,
662-
entry.value is TextEditingController
663-
? (entry.value as TextEditingController).text
664-
: entry.value)));
674+
return Map.fromEntries(
675+
_metadataControllers.entries.map(
676+
(entry) => MapEntry(
677+
entry.key,
678+
entry.value is TextEditingController
679+
? (entry.value as TextEditingController).text
680+
: entry.value,
681+
),
682+
),
683+
);
665684
}
666685
}

lib/src/components/supa_magic_auth.dart

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,13 @@ class _SupaMagicAuthState extends State<SupaMagicAuth> {
5454
@override
5555
void initState() {
5656
super.initState();
57-
_gotrueSubscription =
58-
Supabase.instance.client.auth.onAuthStateChange.listen((data) {
59-
final session = data.session;
60-
if (session != null && mounted) {
61-
widget.onSuccess(session);
62-
}
63-
});
57+
_gotrueSubscription = Supabase.instance.client.auth.onAuthStateChange
58+
.listen((data) {
59+
final session = data.session;
60+
if (session != null && mounted) {
61+
widget.onSuccess(session);
62+
}
63+
});
6464
}
6565

6666
@override
@@ -119,7 +119,8 @@ class _SupaMagicAuthState extends State<SupaMagicAuth> {
119119
} catch (error) {
120120
if (widget.onError == null && context.mounted) {
121121
context.showErrorSnackBar(
122-
'${localization.unexpectedError}: $error');
122+
'${localization.unexpectedError}: $error',
123+
);
123124
} else {
124125
widget.onError?.call(error);
125126
}
@@ -169,7 +170,8 @@ class _SupaMagicAuthState extends State<SupaMagicAuth> {
169170
} catch (error) {
170171
if (widget.onError == null && context.mounted) {
171172
context.showErrorSnackBar(
172-
'${localization.unexpectedError}: $error');
173+
'${localization.unexpectedError}: $error',
174+
);
173175
} else {
174176
widget.onError?.call(error);
175177
}

lib/src/components/supa_phone_auth.dart

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,8 @@ class _SupaPhoneAuthState extends State<SupaPhoneAuth> {
139139
} catch (error) {
140140
if (widget.onError == null && context.mounted) {
141141
context.showErrorSnackBar(
142-
'${localization.unexpectedError}: $error');
142+
'${localization.unexpectedError}: $error',
143+
);
143144
} else {
144145
widget.onError?.call(error);
145146
}
@@ -196,7 +197,8 @@ class _SupaPhoneAuthState extends State<SupaPhoneAuth> {
196197
} catch (error) {
197198
if (widget.onError == null && context.mounted) {
198199
context.showErrorSnackBar(
199-
'${localization.unexpectedError}: $error');
200+
'${localization.unexpectedError}: $error',
201+
);
200202
} else {
201203
widget.onError?.call(error);
202204
}

0 commit comments

Comments
 (0)