From 912a4af86646328bd454a4f6f359de73b2a72fbe Mon Sep 17 00:00:00 2001 From: Serhii Date: Fri, 20 Jan 2023 23:18:58 +0200 Subject: [PATCH] fix nullable type --- ...let_address_edit_or_create_view_model.dart | 37 ++++++++----------- 1 file changed, 16 insertions(+), 21 deletions(-) diff --git a/lib/view_model/wallet_address_list/wallet_address_edit_or_create_view_model.dart b/lib/view_model/wallet_address_list/wallet_address_edit_or_create_view_model.dart index c29a256df..2cca395ab 100644 --- a/lib/view_model/wallet_address_list/wallet_address_edit_or_create_view_model.dart +++ b/lib/view_model/wallet_address_list/wallet_address_edit_or_create_view_model.dart @@ -99,27 +99,22 @@ abstract class WalletAddressEditOrCreateViewModelBase with Store { await wallet.walletAddresses.updateAddress(_item.address as String); await wallet.save(); }*/ - - if (wallet.type == WalletType.monero) { - await monero - !.getSubaddressList(wallet) - .setLabelSubaddress( - wallet, - accountIndex: monero!.getCurrentAccount(wallet).id, - addressIndex: _item?.id as int, - label: label); - await wallet.save(); - } - - if (wallet.type == WalletType.haven) { - await haven - !.getSubaddressList(wallet) - .setLabelSubaddress( - wallet, - accountIndex: haven!.getCurrentAccount(wallet).id, - addressIndex: _item?.id as int, - label: label); - await wallet.save(); + final index = _item?.id; + if (index != null) { + if (wallet.type == WalletType.monero) { + await monero!.getSubaddressList(wallet).setLabelSubaddress(wallet, + accountIndex: monero!.getCurrentAccount(wallet).id, addressIndex: index, label: label); + await wallet.save(); + return; + } + if (wallet.type == WalletType.haven) { + await haven!.getSubaddressList(wallet).setLabelSubaddress(wallet, + accountIndex: haven!.getCurrentAccount(wallet).id, + addressIndex: _item?.id as int, + label: label); + await wallet.save(); + return; + } } } }