mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2024-12-23 03:59:23 +00:00
26 lines
587 B
Dart
26 lines
587 B
Dart
|
import 'package:intl/intl.dart';
|
||
|
|
||
|
const polygonAmountLength = 12;
|
||
|
const polygonAmountDivider = 1000000000000;
|
||
|
final polygonAmountFormat = NumberFormat()
|
||
|
..maximumFractionDigits = polygonAmountLength
|
||
|
..minimumFractionDigits = 1;
|
||
|
|
||
|
class PolygonFormatter {
|
||
|
static int parsePolygonAmount(String amount) {
|
||
|
try {
|
||
|
return (double.parse(amount) * polygonAmountDivider).round();
|
||
|
} catch (_) {
|
||
|
return 0;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
static double parsePolygonAmountToDouble(int amount) {
|
||
|
try {
|
||
|
return amount / polygonAmountDivider;
|
||
|
} catch (_) {
|
||
|
return 0;
|
||
|
}
|
||
|
}
|
||
|
}
|