cake_wallet/lib/bitcoin/bitcoin_amount_format.dart

16 lines
645 B
Dart
Raw Normal View History

2020-05-12 12:04:54 +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-05-12 12:04:54 +00:00
const bitcoinAmountLength = 8;
const bitcoinAmountDivider = 100000000;
final bitcoinAmountFormat = NumberFormat()
..maximumFractionDigits = bitcoinAmountLength
..minimumFractionDigits = 1;
String bitcoinAmountToString({int amount}) =>
bitcoinAmountFormat.format(cryptoAmountToDouble(amount: amount, divider: bitcoinAmountDivider));
double bitcoinAmountToDouble({int amount}) => cryptoAmountToDouble(amount: amount, divider: bitcoinAmountDivider);
2020-09-21 11:50:26 +00:00
int doubleToBitcoinAmount(double amount) =>
(amount * bitcoinAmountDivider).toInt();