What changed, and why it matters
This is a small defensive UI fix in the cryptocurrency wallet's send/swap flow. Before popping a screen, the code now checks that the widget is still active and that there is actually a screen to go back to. This prevents a potential app crash if a user triggers the swap flow when there is no previous screen to return to, or after the screen has been closed.
No urgent action needed. Treat as routine hardening. If the crash was user-reported, verify the reproduction path is closed and consider adding automated widget tests for the swap flow.
Security signals we found
UI state guard added before navigator pop
Potential unhandled exception / crash path removed
No cryptographic, authentication, or storage changes
Evidence from the diff
In lib/src/screens/send/widgets/send_card.dart, the _handleSwapFlow method previously unconditionally called Navigator.of(context).pop(). The patch guards that call with two checks: mounted (the State object is still in the widget tree) and Navigator.of(context).canPop() (the navigator has a route below the current one). This is a hardening change against calling pop() in an invalid state, which in Flutter can throw or produce black screens.
Changed components
lib/src/screens/send/widgets/send_card.dartSwap/send flow UI navigationInspect captured patch +3 / −1
diff --git a/lib/src/screens/send/widgets/send_card.dart b/lib/src/screens/send/widgets/send_card.dart
index 3a1e0c71..007b9005 100644
--- a/lib/src/screens/send/widgets/send_card.dart
+++ b/lib/src/screens/send/widgets/send_card.dart
@@ -347,7 +347,9 @@ class SendCardState extends State<SendCard> with AutomaticKeepAliveClientMixin<S
}
Future<void> _handleSwapFlow(PaymentViewModel paymentViewModel, PaymentFlowResult result) async {
- Navigator.of(context).pop();
+ if (mounted && Navigator.of(context).canPop()) {
+ Navigator.of(context).pop();
+ }
final bottomSheet = getIt.get<SwapConfirmationBottomSheet>(param1: result);
await showModalBottomSheet<Trade?>(
context: context,
Why this scored 21/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.