Skip to content

Commit 4ec09d0

Browse files
committed
Fix use of BuildContext's across async gaps
1 parent 983602c commit 4ec09d0

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

lib/src/components/supa_email_auth.dart

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

lib/src/components/supa_reset_password.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,9 @@ class _SupaResetPasswordState extends State<SupaResetPassword> {
7878
),
7979
);
8080
widget.onSuccess.call(response);
81-
context.showSnackBar(localization.passwordResetSent);
81+
if (mounted) {
82+
context.showSnackBar(localization.passwordResetSent);
83+
}
8284
} on AuthException catch (error) {
8385
if (widget.onError == null && context.mounted) {
8486
context.showErrorSnackBar(error.message);

0 commit comments

Comments
 (0)