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

Fix MetadataFields text field values being lost in SupaEmailAuth widget (Fixes #113) #114

Merged
merged 2 commits into from
Oct 1, 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
10 changes: 5 additions & 5 deletions lib/src/components/supa_email_auth.dart
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ class _SupaEmailAuthState extends State<SupaEmailAuth> {
final _formKey = GlobalKey<FormState>();
final _emailController = TextEditingController();
final _passwordController = TextEditingController();
late final Map<MetaDataField, TextEditingController> _metadataControllers;
late final Map<String, TextEditingController> _metadataControllers;

bool _isLoading = false;

Expand All @@ -142,7 +142,8 @@ class _SupaEmailAuthState extends State<SupaEmailAuth> {
void initState() {
super.initState();
_metadataControllers = Map.fromEntries((widget.metadataFields ?? []).map(
(metadataField) => MapEntry(metadataField, TextEditingController())));
(metadataField) =>
MapEntry(metadataField.key, TextEditingController())));
}

@override
Expand Down Expand Up @@ -225,7 +226,7 @@ class _SupaEmailAuthState extends State<SupaEmailAuth> {
...widget.metadataFields!
.map((metadataField) => [
TextFormField(
controller: _metadataControllers[metadataField],
controller: _metadataControllers[metadataField.key],
textInputAction:
widget.metadataFields!.last == metadataField
? TextInputAction.done
Expand Down Expand Up @@ -423,8 +424,7 @@ class _SupaEmailAuthState extends State<SupaEmailAuth> {
Map<String, dynamic> _resolveMetadataFieldsData() {
return widget.metadataFields != null
? _metadataControllers.map<String, dynamic>(
(metaDataField, controller) =>
MapEntry(metaDataField.key, controller.text))
(key, controller) => MapEntry(key, controller.text))
: <String, dynamic>{};
}
}
Loading