Skip to content

Commit ea1563c

Browse files
committed
Fix use of BuildContext's across async gaps in SupaEmailAuth and SupaResetPassword
1 parent 4ec09d0 commit ea1563c

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

lib/src/components/supa_email_auth.dart

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -298,12 +298,12 @@ class _SupaEmailAuthState extends State<SupaEmailAuth> {
298298
redirectTo: widget.redirectTo,
299299
);
300300
widget.onPasswordResetEmailSent?.call();
301-
if (mounted) {
302-
context.showSnackBar(localization.passwordResetSent);
303-
setState(() {
304-
_forgotPassword = false;
305-
});
306-
}
301+
// FIX use_build_context_synchronously
302+
if (!context.mounted) return;
303+
context.showSnackBar(localization.passwordResetSent);
304+
setState(() {
305+
_forgotPassword = false;
306+
});
307307
} on AuthException catch (error) {
308308
widget.onError?.call(error);
309309
} catch (error) {

lib/src/components/supa_reset_password.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,9 @@ class _SupaResetPasswordState extends State<SupaResetPassword> {
7878
),
7979
);
8080
widget.onSuccess.call(response);
81-
if (mounted) {
82-
context.showSnackBar(localization.passwordResetSent);
83-
}
81+
// FIX use_build_context_synchronously
82+
if (!context.mounted) return;
83+
context.showSnackBar(localization.passwordResetSent);
8484
} on AuthException catch (error) {
8585
if (widget.onError == null && context.mounted) {
8686
context.showErrorSnackBar(error.message);

0 commit comments

Comments
 (0)