From 235b731c1977253ae02a9c9d0ee75b747b998f70 Mon Sep 17 00:00:00 2001 From: sneurlax Date: Tue, 20 Feb 2024 12:41:22 -0600 Subject: [PATCH 1/2] null wallet fix pt 1 --- lib/services/wallets.dart | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/services/wallets.dart b/lib/services/wallets.dart index b56a6b090..729b863ee 100644 --- a/lib/services/wallets.dart +++ b/lib/services/wallets.dart @@ -42,7 +42,13 @@ class Wallets { final Map _wallets = {}; - Wallet getWallet(String walletId) => _wallets[walletId]!; + Wallet getWallet(String walletId) { + if (_wallets[walletId] != null) { + return _wallets[walletId]!; + } else { + throw Exception("Wallet with id $walletId not found"); + } + } void addWallet(Wallet wallet) { if (_wallets[wallet.walletId] != null) { From 04ca80529a03892af93526737d5dddc418e1191c Mon Sep 17 00:00:00 2001 From: sneurlax Date: Tue, 20 Feb 2024 17:32:02 -0600 Subject: [PATCH 2/2] finally dismiss restoration failed dialog --- .../sub_widgets/restore_failed_dialog.dart | 23 +++++++++++++------ 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/lib/pages/add_wallet_views/restore_wallet_view/sub_widgets/restore_failed_dialog.dart b/lib/pages/add_wallet_views/restore_wallet_view/sub_widgets/restore_failed_dialog.dart index ea77f9d33..02f4e714b 100644 --- a/lib/pages/add_wallet_views/restore_wallet_view/sub_widgets/restore_failed_dialog.dart +++ b/lib/pages/add_wallet_views/restore_wallet_view/sub_widgets/restore_failed_dialog.dart @@ -13,6 +13,7 @@ import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:stackwallet/providers/global/secure_store_provider.dart'; import 'package:stackwallet/providers/providers.dart'; import 'package:stackwallet/themes/stack_colors.dart'; +import 'package:stackwallet/utilities/logger.dart'; import 'package:stackwallet/utilities/text_styles.dart'; import 'package:stackwallet/wallets/isar/providers/wallet_info_provider.dart'; import 'package:stackwallet/widgets/stack_dialog.dart'; @@ -65,13 +66,21 @@ class _RestoreFailedDialogState extends ConsumerState { style: STextStyles.itemSubtitle12(context), ), onPressed: () async { - await ref.read(pWallets).deleteWallet( - ref.read(pWalletInfo(walletId)), - ref.read(secureStoreProvider), - ); - - if (mounted) { - Navigator.of(context).pop(); + try { + await ref.read(pWallets).deleteWallet( + ref.read(pWalletInfo(walletId)), + ref.read(secureStoreProvider), + ); + } catch (e, s) { + Logging.instance.log( + "Error while getting wallet info in restore failed dialog\n" + "Error: $e\nStack trace: $s", + level: LogLevel.Error, + ); + } finally { + if (mounted) { + Navigator.of(context).pop(); + } } }, ),