Add more guards to amounts being zero or infinity (#3612)

* Add more guards to amounts being zero or infinity

* Add more guards to amounts being zero or infinity
This commit is contained in:
Omar Hatem
2026-09-12 18:59:00 +02:00
committed by GitHub
parent 8d75c3f0c3
commit 3bb64b71ac
9 changed files with 179 additions and 11 deletions
+2 -1
View File
@@ -8,8 +8,9 @@ String calculateFiatAmount({double? price, String? cryptoAmount, bool raw = fals
cryptoAmount = cryptoAmount.sanitized();
final _amount = double.tryParse(cryptoAmount);
if (_amount == null || _amount.isNaN) return '0.00';
if (_amount == null || !_amount.isFinite) return '0.00';
final _result = price * _amount;
if (!_result.isFinite) return '0.00';
final result = _result < 0 ? _result * -1 : _result;
if (result == 0.0) {
@@ -7,6 +7,10 @@ String calculateFiatAmountRaw({required double cryptoAmount, double? price}) {
final result = price * cryptoAmount;
if (!result.isFinite) {
return '0.00';
}
if (result == 0.0) {
return '0.00';
}