Skip to content

fix: add mounted check after async gap in OTP resend#254

Open
Priyanshu-byte-coder wants to merge 1 commit into
AOSSIE-Org:mainfrom
Priyanshu-byte-coder:fix/mounted-check-after-async-gaps
Open

fix: add mounted check after async gap in OTP resend#254
Priyanshu-byte-coder wants to merge 1 commit into
AOSSIE-Org:mainfrom
Priyanshu-byte-coder:fix/mounted-check-after-async-gaps

Conversation

@Priyanshu-byte-coder

Copy link
Copy Markdown

Summary

Closes #224

ScaffoldMessenger.of(context) was called after await resendVerificationEmail() in verify_otp_screen.dart without checking if (mounted). If the user navigated back while the async call was in flight, the widget would be disposed and calling ScaffoldMessenger.of(context) would crash with: "Looking up a deactivated widget's ancestor is unsafe".

Fix

Added if (!mounted) return; immediately after the await and before any context usage in the resend flow.

// Before
final result = await _supabaseService.resendVerificationEmail(...);
if (result['success']) {
  ScaffoldMessenger.of(context).showSnackBar(...); // ❌ no mounted check

// After
final result = await _supabaseService.resendVerificationEmail(...);
if (!mounted) return; // ✅ guard added
if (result['success']) {
  ScaffoldMessenger.of(context).showSnackBar(...);

File changed

  • lib/screens/auth/verify_otp_screen.dart — line 204 (after resend await)

@coderabbitai

coderabbitai Bot commented May 14, 2026

Copy link
Copy Markdown
Contributor

Warning

Rate limit exceeded

@Priyanshu-byte-coder has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 53 minutes and 7 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: a233fc77-7413-4a20-830c-f41d0f863b41

📥 Commits

Reviewing files that changed from the base of the PR and between 1cea2a6 and 076c91f.

📒 Files selected for processing (1)
  • lib/screens/auth/verify_otp_screen.dart
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BUG: BuildContext used after async gap in auth (verify OTP) and profile (logout) screens

1 participant