cake_wallet/lib/entities/calculate_fiat_amount.dart

14 lines
329 B
Dart
Raw Normal View History

2020-01-04 19:31:52 +00:00
String calculateFiatAmount({double price, String cryptoAmount}) {
if (price == null || cryptoAmount == null) {
return '0.00';
}
final _amount = double.parse(cryptoAmount);
final result = price * _amount;
if (result == 0.0) {
return '0.00';
}
return result > 0.01 ? result.toStringAsFixed(2) : '< 0.01';
}