What changed, and why it matters
This is a small defensive fix in a mobile wallet's gift-card purchase screen. It checks that the Flutter UI context is still active before opening a bottom-sheet popup. Without the check, the app could try to display a popup after the user had already left the screen, which can cause a crash or a confusing error message. It is a stability/reliability improvement, not a security vulnerability fix.
No security action required. Treat as a routine stability fix. If auditing, verify other async bottom-sheet or dialog calls in the Cake Pay flow use similar mounted checks.
Security signals we found
Defensive lifecycle guard added for async UI operation
No change to input validation, crypto, network, or permissions
No mention of security, CVE, researcher, or exploit in commit
Evidence from the diff
The patch adds a if (!sheetParentCtx.mounted) return; guard before showModalBottomSheet in CakePayBuyCardPage. In Flutter, calling showModalBottomSheet with a BuildContext whose widget is no longer mounted throws an assertion error / exception. The change prevents an asynchronous continuation from presenting a sheet on a disposed context. This is a defensive null/state-lifecycle fix; it does not alter trust boundaries, input validation, cryptography, or network behavior.
Changed components
lib/cake_pay/src/cards/cake_pay_buy_card_page.dartCakePay gift card purchase bottom-sheet presentationInspect captured patch +4 / −0
diff --git a/lib/cake_pay/src/cards/cake_pay_buy_card_page.dart b/lib/cake_pay/src/cards/cake_pay_buy_card_page.dart
index 926e9f04..68d60601 100644
--- a/lib/cake_pay/src/cards/cake_pay_buy_card_page.dart
+++ b/lib/cake_pay/src/cards/cake_pay_buy_card_page.dart
@@ -682,6 +682,10 @@ class CakePayBuyCardPage extends BasePage {
final BuildContext sheetParentCtx = usePageContextLater ? context : _overlayCtx;
+ if (!sheetParentCtx.mounted) {
+ return;
+ }
+
await showModalBottomSheet<void>(
context: sheetParentCtx,
useRootNavigator: !usePageContextLater,
Why this scored 28/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.