fix: add mounted guard after async network calls in AmountScreen - #115
fix: add mounted guard after async network calls in AmountScreen#115Delgado74 wants to merge 2 commits into
Conversation
Add if (!mounted) return; after await _invoiceService.sendPaymentToLNURL and await _invoiceService.sendPaymentToLightningAddress to prevent potential crashes when the user navigates away during a payment request. Closes lachispame#67
|
Warning Review limit reached
More reviews will be available in 58 minutes and 54 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the 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 include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
Summary
Closes #67
Adds
if (!mounted) return;guards after async network calls in_processLNURLPaymentand_processLightningAddressPaymentto prevent potential crashes when the user navigates away during an in-flight payment request.Problem
After
await _invoiceService.sendPaymentToLNURL(...)andawait _invoiceService.sendPaymentToLightningAddress(...), the code calls_showPendingSnackBar,_showSuccessSnackBar, andNavigator.of(context).popUntilwithout checking if the widget is still mounted. If the user presses back while the request is in flight:BuildContextbecomes invalidcontext.tokensorScaffoldMessenger.of(context)can throw an exceptionWhile timing may prevent a crash in many cases (fast response, slow user), the race condition exists and eliminating it is trivial.
Changes
lib/screens/11amount_screen.dartif (!mounted) return;after the two async network calls (lines +415, +494)Testing
flutter analyzepasses with no new issues.