What changed, and why it matters
This commit is a routine code cleanup in a single Flutter UI file. It replaces verbose 'return { ... }' function bodies with arrow syntax, adds 'const' keywords where Flutter can optimize widget rebuilds, and tweaks one loading-state update to check whether the widget is still on screen before calling setState. There is no visible change in behavior for users and no indication of a security fix.
No security action needed. Treat as normal maintenance; review and merge through standard QA if desired.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The diff in lib/new-ui/widgets/send_page/send_confirm_sheet.dart is purely refactor/style: converting build methods to expression-bodied arrow functions, adding const constructors for immutable widgets (EdgeInsets, BorderRadius, TextStyle, ValueKey, SizedBox, Icon, Padding, CakeImageWidget, CupertinoActivityIndicator), removing redundant parentheses around negated boolean expressions, and guarding a setState call with a mounted check. No logic, validation, cryptography, navigation, or transaction-handling behavior is altered.
Changed components
lib/new-ui/widgets/send_page/send_confirm_sheet.dartInspect captured patch +29 / −44
### lib/new-ui/widgets/send_page/send_confirm_sheet.dart
@@ -54,8 +54,7 @@ class _SendConfirmSheetState extends State<SendConfirmSheet> {
}
@override
- Widget build(BuildContext context) {
- return PopScope(
+ Widget build(BuildContext context) => PopScope(
canPop: !widget.isPage,
onPopInvokedWithResult: (didPop, result) {
if (widget.isPage) {
@@ -64,11 +63,11 @@ class _SendConfirmSheetState extends State<SendConfirmSheet> {
},
child: SafeArea(
bottom: false,
- minimum: widget.isPage ? EdgeInsets.zero : EdgeInsets.only(top: 64),
+ minimum: widget.isPage ? EdgeInsets.zero : const EdgeInsets.only(top: 64),
child: Container(
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.surface,
- borderRadius: BorderRadius.vertical(top: Radius.circular(16)),
+ borderRadius: const BorderRadius.vertical(top: Radius.circular(16)),
),
child: SafeArea(child: Observer(
builder: (_) {
@@ -122,7 +121,6 @@ class _SendConfirmSheetState extends State<SendConfirmSheet> {
),
),
);
- }
}
class SendTransactionDetails extends StatelessWidget {
@@ -139,9 +137,8 @@ class SendTransactionDetails extends StatelessWidget {
final resolvedIconPath = iconPath ?? sendViewModel.currency.iconPath ?? "";
return LayoutBuilder(
- builder: (context, constraints) {
- return Column(
- key: ValueKey(0),
+ builder: (context, constraints) => Column(
+ key: const ValueKey(0),
mainAxisSize: isPage ? MainAxisSize.max : MainAxisSize.min,
children: [
ModalTopBar(
@@ -168,20 +165,19 @@ class SendTransactionDetails extends StatelessWidget {
headingLevel: 1,
child: Text(
title ?? S.of(context).send,
- style: TextStyle(fontWeight: FontWeight.w500, fontSize: 20),
+ style: const TextStyle(fontWeight: FontWeight.w500, fontSize: 20),
),
)
],
),
- trailingIcon: Icon(Icons.close),
+ trailingIcon: const Icon(Icons.close),
trailingSemanticLabel: S.of(context).close,
onTrailingPressed: Navigator.of(context).maybePop,
),
isPage
? Expanded(child: _buildMainContent(context))
: Flexible(child: _buildMainContent(context))
- ]);
- },
+ ]),
);
}
@@ -198,8 +194,7 @@ class SendTransactionDetails extends StatelessWidget {
return "${decimals == null ? str : str.withDecimals(decimals)} $unit";
}
- Widget _buildMainContent(BuildContext context) {
- return Observer(builder: (context) {
+ Widget _buildMainContent(BuildContext context) => Observer(builder: (context) {
final transaction = sendViewModel.pendingTransaction;
final additionalCostNotice = sendViewModel.pendingTransactionAdditionalCostNotice;
@@ -421,7 +416,7 @@ class SendTransactionDetails extends StatelessWidget {
],
if (sendViewModel.isElectrumWallet) ...[
Padding(
- padding: EdgeInsets.symmetric(horizontal: 12),
+ padding: const EdgeInsets.symmetric(horizontal: 12),
child: Container(
height: 1,
color: Theme.of(context).colorScheme.surfaceContainerHigh,
@@ -460,13 +455,12 @@ class SendTransactionDetails extends StatelessWidget {
),
SendConfirmBottomWidget(sendViewModel: sendViewModel),
if (Platform.isAndroid) // spacing between bottom widget and system navbar
- SizedBox(),
+ const SizedBox(),
],
),
),
);
});
- }
String formatAmount(String amount) {
try {
@@ -490,27 +484,24 @@ class _TransactionCommitedScreenState extends State<TransactionCommitedScreen> {
bool _isNoteButtonLoading = false;
@override
- Widget build(BuildContext context) {
- return Observer(
+ Widget build(BuildContext context) => Observer(
builder: (_) => Column(
spacing: 12,
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
- SizedBox(
- height: 12,
- ),
+ const SizedBox(height: 12),
// The sheet swaps its content in place, so this title becoming visible is what
// tells a screen reader that the transaction went through.
Semantics(
liveRegion: true,
child: Text(
S.of(context).transaction_sent_new,
- style: TextStyle(fontSize: 24, fontWeight: FontWeight.w600),
+ style: const TextStyle(fontSize: 24, fontWeight: FontWeight.w600),
),
),
- SizedBox(),
- CakeImageWidget(width: 200, height: 200, imageUrl: "assets/new-ui/birthday_cake.svg"),
+ const SizedBox(),
+ const CakeImageWidget(width: 200, height: 200, imageUrl: "assets/new-ui/birthday_cake.svg"),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 24.0),
child: Column(
@@ -520,9 +511,9 @@ class _TransactionCommitedScreenState extends State<TransactionCommitedScreen> {
Row(
spacing: 8,
children: [
- if (!(widget.sendViewModel!.checkIfAddressIsAContact(
- widget.sendViewModel!.outputs.first.address)) &&
- !(widget.sendViewModel!.outputs.first.isParsedAddress))
+ if (!widget.sendViewModel!.checkIfAddressIsAContact(
+ widget.sendViewModel!.outputs.first.address) &&
+ !widget.sendViewModel!.outputs.first.isParsedAddress)
TransactionCommittedScreenActionButton(
text: S.of(context).save_contact,
iconPath: "assets/new-ui/save_contact.svg",
@@ -551,9 +542,10 @@ class _TransactionCommitedScreenState extends State<TransactionCommitedScreen> {
// for other currs this is instant
await asyncWhen((_) => widget.sendViewModel!.transactionInfo != null);
- setState(() {
- _isNoteButtonLoading = false;
- });
+ _isNoteButtonLoading = false;
+ if (mounted) {
+ setState(() {});
+ }
final page = getIt.get<TransactionDetailsModal>(
param1: widget.sendViewModel!.transactionInfo!, param2: true);
@@ -570,16 +562,13 @@ class _TransactionCommitedScreenState extends State<TransactionCommitedScreen> {
text: S.of(context).done,
color: Theme.of(context).colorScheme.primary,
textColor: Theme.of(context).colorScheme.onPrimary),
- SizedBox(
- height: 12,
- )
+ const SizedBox(height: 12),
],
),
),
],
),
);
- }
}
class TransactionCommittedScreenActionButton extends StatelessWidget {
@@ -596,8 +585,7 @@ class TransactionCommittedScreenActionButton extends StatelessWidget {
final bool isLoading;
@override
- Widget build(BuildContext context) {
- return Flexible(
+ Widget build(BuildContext context) => Flexible(
child: Semantics(
button: true,
enabled: !isLoading,
@@ -612,13 +600,13 @@ class TransactionCommittedScreenActionButton extends StatelessWidget {
borderRadius: BorderRadius.circular(16),
color: Theme.of(context).colorScheme.surfaceContainer),
child: Padding(
- padding: EdgeInsets.all(16),
+ padding: const EdgeInsets.all(16),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
spacing: 10,
children: [
isLoading
- ? CupertinoActivityIndicator()
+ ? const CupertinoActivityIndicator()
: CakeImageWidget(
imageUrl: iconPath,
width: 24,
@@ -636,7 +624,6 @@ class TransactionCommittedScreenActionButton extends StatelessWidget {
),
),
))));
- }
}
class MultiSendAddressPreview extends StatefulWidget {
@@ -660,8 +647,7 @@ class _MultiSendAddressPreviewState extends State<MultiSendAddressPreview> {
bool _expanded = false;
@override
- Widget build(BuildContext context) {
- return Padding(
+ Widget build(BuildContext context) => Padding(
padding: const EdgeInsets.all(12.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
@@ -673,7 +659,7 @@ class _MultiSendAddressPreviewState extends State<MultiSendAddressPreview> {
children: [
Text(
"${widget.index}:",
- style: TextStyle(fontFamily: "IBM Plex Mono"),
+ style: const TextStyle(fontFamily: "IBM Plex Mono"),
),
if (!_expanded)
Semantics(
@@ -721,5 +707,4 @@ class _MultiSendAddressPreviewState extends State<MultiSendAddressPreview> {
],
),
);
- }
}Why this scored 15/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.