cake_wallet/lib/monero/monero_amount_format.dart

18 lines
658 B
Dart
Raw Normal View History

2020-01-04 19:31:52 +00:00
import 'package:intl/intl.dart';
2020-09-21 11:50:26 +00:00
import 'package:cake_wallet/entities/crypto_amount_format.dart';
2020-01-04 19:31:52 +00:00
const moneroAmountLength = 12;
const moneroAmountDivider = 1000000000000;
final moneroAmountFormat = NumberFormat()
..maximumFractionDigits = moneroAmountLength
..minimumFractionDigits = 1;
2020-11-08 20:44:09 +00:00
String moneroAmountToString({int amount}) => moneroAmountFormat
.format(cryptoAmountToDouble(amount: amount, divider: moneroAmountDivider));
2020-01-04 19:31:52 +00:00
2020-11-08 20:44:09 +00:00
double moneroAmountToDouble({int amount}) =>
cryptoAmountToDouble(amount: amount, divider: moneroAmountDivider);
2020-06-01 18:13:56 +00:00
2020-11-08 20:44:09 +00:00
int moneroParseAmount({String amount}) =>
(double.parse(amount) * moneroAmountDivider).toInt();