From 4fc2a7acfa931ae40c5a883c36e6d61d82993327 Mon Sep 17 00:00:00 2001 From: julian Date: Tue, 17 Dec 2024 19:23:56 -0600 Subject: [PATCH] fix: optional cast error --- .../wallet_network_settings_view.dart | 10 ++++++---- lib/wallets/wallet/wallet.dart | 4 +++- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/lib/pages/settings_views/wallet_settings_view/wallet_network_settings_view/wallet_network_settings_view.dart b/lib/pages/settings_views/wallet_settings_view/wallet_network_settings_view/wallet_network_settings_view.dart index f8eb344a8..5b3a2eb07 100644 --- a/lib/pages/settings_views/wallet_settings_view/wallet_network_settings_view/wallet_network_settings_view.dart +++ b/lib/pages/settings_views/wallet_settings_view/wallet_network_settings_view/wallet_network_settings_view.dart @@ -234,10 +234,12 @@ class _WalletNetworkSettingsViewState _percent = 1; _blocksRemaining = 0; } else { - _percent = - (ref.read(pWallets).getWallet(widget.walletId) as ElectrumXInterface?) - ?.refreshingPercent ?? - 0; + final wallet = ref.read(pWallets).getWallet(widget.walletId); + if (wallet is ElectrumXInterface) { + _percent = wallet.refreshingPercent ?? 0; + } else { + _percent = 0; + } _blocksRemaining = -1; } diff --git a/lib/wallets/wallet/wallet.dart b/lib/wallets/wallet/wallet.dart index b0516b74e..4445ba7a9 100644 --- a/lib/wallets/wallet/wallet.dart +++ b/lib/wallets/wallet/wallet.dart @@ -565,7 +565,9 @@ abstract class Wallet { } void _fireRefreshPercentChange(double percent) { - (this as ElectrumXInterface?)?.refreshingPercent = percent; + if (this is ElectrumXInterface) { + (this as ElectrumXInterface?)?.refreshingPercent = percent; + } GlobalEventBus.instance.fire(RefreshPercentChangedEvent(percent, walletId)); }