Aidra Connect 10.0.2+16
Aidra Connect Mobile Application
Loading...
Searching...
No Matches
number_conversion.dart
Go to the documentation of this file.
2 static double kgToMetricTon(num? kg) {
3 if (kg == null) return 0.0;
4 return kg / 1000;
5 }
6
7 static String formatWithCommas(num? value) {
8 if (value == null) return "0.00";
9 return value.toStringAsFixed(2).replaceAllMapped(
10 RegExp(r'(\d)(?=(\d{3})+(?!\d))'), (Match m) => '${m[1]},');
11 }
12
13 static String convertAndFormatWeight(num? kg) {
14 if (kg == null || kg < 1000) {
15 return "${formatWithCommas(kg ?? 0)} kg";
16 }
17 double mt = kgToMetricTon(kg);
18 return "${formatWithCommas(mt)} Mt";
19 }
20}
static double kgToMetricTon(num? kg)
static String formatWithCommas(num? value)
static String convertAndFormatWeight(num? kg)
final double value