What changed, and why it matters
This is a small UI stability fix in the cryptocurrency swap screen. It replaces a forceful 'this widget must exist' access with a safer 'if it exists' check for the receive-amount field. The change prevents the app from crashing if the receive-side widget has not finished building when the user types or changes settings. There is no indication this allows theft of funds, bypass of security checks, or remote exploitation.
Treat as a routine stability fix. No urgent security action is required. Include in normal release testing to confirm the swap page no longer crashes during rapid input or widget rebuilds.
Security signals we found
Null-safety hardening in UI code
Crash-prevention only; no security boundary crossed
No input validation, authentication, cryptography, or transaction logic changed
Evidence from the diff
In lib/new-ui/pages/swap_page.dart, two uses of receiveKey.currentState! (null-assertion) are changed to receiveKey.currentState? or an explicit null check. The first call to updateFiatAmount() now safely does nothing if the GlobalKey has no current State. The second call is guarded by receiveKey.currentState != null before reading amountFocusNode.hasFocus. This is a defensive null-safety fix that avoids a StateError/NullPointerException during widget lifecycle transitions.
Changed components
lib/new-ui/pages/swap_page.dartNewSwapPage receive-amount widget state accessInspect captured patch +3 / −2
diff --git a/lib/new-ui/pages/swap_page.dart b/lib/new-ui/pages/swap_page.dart
index 54c003ec..1d842789 100644
--- a/lib/new-ui/pages/swap_page.dart
+++ b/lib/new-ui/pages/swap_page.dart
@@ -132,7 +132,7 @@ class _NewSwapPageState extends State<NewSwapPage> {
if (double.tryParse(depositFiatAmountController.text) != null) {
widget.exchangeViewModel
.setDepositAmountFromFiat(fiatAmount: depositFiatAmountController.text);
- receiveKey.currentState!.updateFiatAmount();
+ receiveKey.currentState?.updateFiatAmount();
}
});
});
@@ -302,7 +302,8 @@ class _NewSwapPageState extends State<NewSwapPage> {
}
widget.exchangeViewModel.isReceiveAmountEntered = false;
widget.exchangeViewModel.isFixedRateMode = false;
- if (!receiveKey.currentState!.amountFocusNode.hasFocus) {
+ if (receiveKey.currentState != null &&
+ !receiveKey.currentState!.amountFocusNode.hasFocus) {
receiveKey.currentState!.updateFiatAmount();
}
});
Why this scored 18/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.