From 1a954333990b688add8558642dc8e6f38f7420ca Mon Sep 17 00:00:00 2001 From: Catrya <140891948+Catrya@users.noreply.github.com> Date: Fri, 25 Jul 2025 14:30:43 -0600 Subject: [PATCH 1/2] Fix Flexible widgets in AlertDialog actions causing crashes --- .../key_manager/key_management_screen.dart | 59 ++++---- .../relays/widgets/relay_selector.dart | 142 ++++++++---------- .../trades/screens/trade_detail_screen.dart | 53 +++---- 3 files changed, 117 insertions(+), 137 deletions(-) diff --git a/lib/features/key_manager/key_management_screen.dart b/lib/features/key_manager/key_management_screen.dart index f0283efe..0b0e68a7 100644 --- a/lib/features/key_manager/key_management_screen.dart +++ b/lib/features/key_manager/key_management_screen.dart @@ -643,43 +643,38 @@ class _KeyManagementScreenState extends ConsumerState { ), ), actions: [ - Flexible( - child: TextButton( - onPressed: () => Navigator.of(dialogContext).pop(), - child: Text( - S.of(context)!.cancel, - style: const TextStyle( - color: AppTheme.textSecondary, - fontSize: 16, - fontWeight: FontWeight.w500, - ), - textAlign: TextAlign.center, + TextButton( + onPressed: () => Navigator.of(dialogContext).pop(), + child: Text( + S.of(context)!.cancel, + style: const TextStyle( + color: AppTheme.textSecondary, + fontSize: 16, + fontWeight: FontWeight.w500, ), + textAlign: TextAlign.center, ), ), - const SizedBox(width: 8), - Flexible( - child: ElevatedButton( - onPressed: () { - Navigator.of(dialogContext).pop(); - _generateNewMasterKey(); - }, - style: ElevatedButton.styleFrom( - backgroundColor: AppTheme.activeColor, - foregroundColor: Colors.black, - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(8), - ), - padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 12), + ElevatedButton( + onPressed: () { + Navigator.of(dialogContext).pop(); + _generateNewMasterKey(); + }, + style: ElevatedButton.styleFrom( + backgroundColor: AppTheme.activeColor, + foregroundColor: Colors.black, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(8), ), - child: Text( - S.of(context)!.continueButton, - style: const TextStyle( - fontSize: 16, - fontWeight: FontWeight.w500, - ), - textAlign: TextAlign.center, + padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 12), + ), + child: Text( + S.of(context)!.continueButton, + style: const TextStyle( + fontSize: 16, + fontWeight: FontWeight.w500, ), + textAlign: TextAlign.center, ), ), ], diff --git a/lib/features/relays/widgets/relay_selector.dart b/lib/features/relays/widgets/relay_selector.dart index b6084c00..57e74eda 100644 --- a/lib/features/relays/widgets/relay_selector.dart +++ b/lib/features/relays/widgets/relay_selector.dart @@ -101,49 +101,44 @@ class RelaySelector extends ConsumerWidget { ), ), actions: [ - Flexible( - child: TextButton( - onPressed: () { - Navigator.pop(dialogContext); - }, - child: Text( - S.of(context)!.cancel, - style: const TextStyle( - color: AppTheme.textSecondary, - fontSize: 16, - fontWeight: FontWeight.w500, - ), - textAlign: TextAlign.center, + TextButton( + onPressed: () { + Navigator.pop(dialogContext); + }, + child: Text( + S.of(context)!.cancel, + style: const TextStyle( + color: AppTheme.textSecondary, + fontSize: 16, + fontWeight: FontWeight.w500, ), + textAlign: TextAlign.center, ), ), - const SizedBox(width: 8), - Flexible( - child: ElevatedButton( - onPressed: () { - final url = controller.text.trim(); - if (url.isNotEmpty) { - final newRelay = Relay(url: url, isHealthy: true); - ref.read(relaysProvider.notifier).addRelay(newRelay); - Navigator.pop(dialogContext); - } - }, - style: ElevatedButton.styleFrom( - backgroundColor: AppTheme.activeColor, - foregroundColor: Colors.black, - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(8), - ), - padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 12), + ElevatedButton( + onPressed: () { + final url = controller.text.trim(); + if (url.isNotEmpty) { + final newRelay = Relay(url: url, isHealthy: true); + ref.read(relaysProvider.notifier).addRelay(newRelay); + Navigator.pop(dialogContext); + } + }, + style: ElevatedButton.styleFrom( + backgroundColor: AppTheme.activeColor, + foregroundColor: Colors.black, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(8), ), - child: Text( - S.of(context)!.add, - style: const TextStyle( - fontSize: 16, - fontWeight: FontWeight.w500, - ), - textAlign: TextAlign.center, + padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 12), + ), + child: Text( + S.of(context)!.add, + style: const TextStyle( + fontSize: 16, + fontWeight: FontWeight.w500, ), + textAlign: TextAlign.center, ), ), ], @@ -189,49 +184,44 @@ class RelaySelector extends ConsumerWidget { ), ), actions: [ - Flexible( - child: TextButton( - onPressed: () => Navigator.pop(dialogContext), - child: Text( - S.of(context)!.cancel, - style: const TextStyle( - color: AppTheme.textSecondary, - fontSize: 16, - fontWeight: FontWeight.w500, - ), - textAlign: TextAlign.center, + TextButton( + onPressed: () => Navigator.pop(dialogContext), + child: Text( + S.of(context)!.cancel, + style: const TextStyle( + color: AppTheme.textSecondary, + fontSize: 16, + fontWeight: FontWeight.w500, ), + textAlign: TextAlign.center, ), ), - const SizedBox(width: 8), - Flexible( - child: ElevatedButton( - onPressed: () { - final newUrl = controller.text.trim(); - if (newUrl.isNotEmpty && newUrl != relay.url) { - final updatedRelay = relay.copyWith(url: newUrl); - ref - .read(relaysProvider.notifier) - .updateRelay(relay, updatedRelay); - } - Navigator.pop(dialogContext); - }, - style: ElevatedButton.styleFrom( - backgroundColor: AppTheme.activeColor, - foregroundColor: Colors.black, - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(8), - ), - padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 12), + ElevatedButton( + onPressed: () { + final newUrl = controller.text.trim(); + if (newUrl.isNotEmpty && newUrl != relay.url) { + final updatedRelay = relay.copyWith(url: newUrl); + ref + .read(relaysProvider.notifier) + .updateRelay(relay, updatedRelay); + } + Navigator.pop(dialogContext); + }, + style: ElevatedButton.styleFrom( + backgroundColor: AppTheme.activeColor, + foregroundColor: Colors.black, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(8), ), - child: Text( - S.of(context)!.save, - style: const TextStyle( - fontSize: 16, - fontWeight: FontWeight.w600, - ), - textAlign: TextAlign.center, + padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 12), + ), + child: Text( + S.of(context)!.save, + style: const TextStyle( + fontSize: 16, + fontWeight: FontWeight.w500, ), + textAlign: TextAlign.center, ), ), ], diff --git a/lib/features/trades/screens/trade_detail_screen.dart b/lib/features/trades/screens/trade_detail_screen.dart index 8b63a929..2ee1e3c2 100644 --- a/lib/features/trades/screens/trade_detail_screen.dart +++ b/lib/features/trades/screens/trade_detail_screen.dart @@ -594,40 +594,35 @@ class TradeDetailScreen extends ConsumerWidget { ), ), actions: [ - Flexible( - child: TextButton( - onPressed: () => Navigator.of(dialogContext).pop(false), - child: Text( - S.of(context)!.no, - style: const TextStyle( - color: AppTheme.textSecondary, - fontSize: 16, - fontWeight: FontWeight.w500, - ), - textAlign: TextAlign.center, + TextButton( + onPressed: () => Navigator.of(dialogContext).pop(false), + child: Text( + S.of(context)!.no, + style: const TextStyle( + color: AppTheme.textSecondary, + fontSize: 16, + fontWeight: FontWeight.w500, ), + textAlign: TextAlign.center, ), ), - const SizedBox(width: 8), - Flexible( - child: ElevatedButton( - onPressed: () => Navigator.of(dialogContext).pop(true), - style: ElevatedButton.styleFrom( - backgroundColor: AppTheme.activeColor, - foregroundColor: Colors.black, - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(8), - ), - padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 12), + ElevatedButton( + onPressed: () => Navigator.of(dialogContext).pop(true), + style: ElevatedButton.styleFrom( + backgroundColor: AppTheme.activeColor, + foregroundColor: Colors.black, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(8), ), - child: Text( - S.of(context)!.yes, - style: const TextStyle( - fontSize: 16, - fontWeight: FontWeight.w600, - ), - textAlign: TextAlign.center, + padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 12), + ), + child: Text( + S.of(context)!.yes, + style: const TextStyle( + fontSize: 16, + fontWeight: FontWeight.w500, ), + textAlign: TextAlign.center, ), ), ], From dba41fb711cd235de955f68a44b7b32c714a5886 Mon Sep 17 00:00:00 2001 From: Catrya <140891948+Catrya@users.noreply.github.com> Date: Fri, 25 Jul 2025 14:52:38 -0600 Subject: [PATCH 2/2] Add spacing between dialog action buttons --- lib/features/key_manager/key_management_screen.dart | 1 + lib/features/relays/widgets/relay_selector.dart | 2 ++ lib/features/trades/screens/trade_detail_screen.dart | 1 + 3 files changed, 4 insertions(+) diff --git a/lib/features/key_manager/key_management_screen.dart b/lib/features/key_manager/key_management_screen.dart index 0b0e68a7..35103eca 100644 --- a/lib/features/key_manager/key_management_screen.dart +++ b/lib/features/key_manager/key_management_screen.dart @@ -655,6 +655,7 @@ class _KeyManagementScreenState extends ConsumerState { textAlign: TextAlign.center, ), ), + const SizedBox(width: 12), ElevatedButton( onPressed: () { Navigator.of(dialogContext).pop(); diff --git a/lib/features/relays/widgets/relay_selector.dart b/lib/features/relays/widgets/relay_selector.dart index 57e74eda..51ff470c 100644 --- a/lib/features/relays/widgets/relay_selector.dart +++ b/lib/features/relays/widgets/relay_selector.dart @@ -115,6 +115,7 @@ class RelaySelector extends ConsumerWidget { textAlign: TextAlign.center, ), ), + const SizedBox(width: 12), ElevatedButton( onPressed: () { final url = controller.text.trim(); @@ -196,6 +197,7 @@ class RelaySelector extends ConsumerWidget { textAlign: TextAlign.center, ), ), + const SizedBox(width: 12), ElevatedButton( onPressed: () { final newUrl = controller.text.trim(); diff --git a/lib/features/trades/screens/trade_detail_screen.dart b/lib/features/trades/screens/trade_detail_screen.dart index 2ee1e3c2..59f56d3f 100644 --- a/lib/features/trades/screens/trade_detail_screen.dart +++ b/lib/features/trades/screens/trade_detail_screen.dart @@ -606,6 +606,7 @@ class TradeDetailScreen extends ConsumerWidget { textAlign: TextAlign.center, ), ), + const SizedBox(width: 12), ElevatedButton( onPressed: () => Navigator.of(dialogContext).pop(true), style: ElevatedButton.styleFrom(