From 2f2c8e34493acea9718ed6e94c61f52faf848d23 Mon Sep 17 00:00:00 2001 From: reasje Date: Wed, 20 Sep 2023 17:30:21 +0330 Subject: [PATCH] fix: Handling exponential numbers --- .../send_token/send_crypto/send_crypto_presenter.dart | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/features/portfolio/subfeatures/token/send_token/send_crypto/send_crypto_presenter.dart b/lib/features/portfolio/subfeatures/token/send_token/send_crypto/send_crypto_presenter.dart index c5844e3f..53cd4b8b 100644 --- a/lib/features/portfolio/subfeatures/token/send_token/send_crypto/send_crypto_presenter.dart +++ b/lib/features/portfolio/subfeatures/token/send_token/send_crypto/send_crypto_presenter.dart @@ -1,4 +1,5 @@ import 'package:datadashwallet/common/config.dart'; +import 'package:datadashwallet/common/utils/utils.dart'; import 'package:datadashwallet/core/core.dart'; import 'package:datadashwallet/features/common/common.dart'; import 'package:datadashwallet/features/common/app_nav_bar/app_nav_bar_presenter.dart'; @@ -37,6 +38,8 @@ class SendCryptoPresenter extends CompletePresenter { final Token token; + late final _transactionHistoryUseCase = + ref.read(transactionHistoryUseCaseProvider); late final TokenContractUseCase _tokenContractUseCase = ref.read(tokenContractUseCaseProvider); late final _accountUseCase = ref.read(accountUseCaseProvider); @@ -114,6 +117,11 @@ class SendCryptoPresenter extends CompletePresenter { double sumBalance = token.balance! - double.parse(amount); estimatedGasFee = await _estimatedFee(recipientAddress); sumBalance -= estimatedGasFee?.gasFee ?? 0.0; + final estimatedFee = estimatedGasFee == null + ? '--' + : Validation.isExpoNumber(estimatedGasFee.gasFee.toString()) + ? '0.000' + : estimatedGasFee.gasFee.toString(); final result = await showTransactionDialog(context!, amount: amount, @@ -122,7 +130,7 @@ class SendCryptoPresenter extends CompletePresenter { newtork: state.network?.label ?? '--', from: state.account!.address, to: recipient, - estimatedFee: estimatedGasFee?.gasFee.toString(), + estimatedFee: estimatedFee, onTap: (transactionType) => _nextTransactionStep(transactionType), networkSymbol: state.network?.symbol ?? '--'); }