Skip to content

Commit

Permalink
feat(number-system-utils): generic class in overall app
Browse files Browse the repository at this point in the history
Signed-off-by: kapdroid <[email protected]>
  • Loading branch information
kapdroid committed Sep 27, 2024
1 parent b7034e2 commit 78a5832
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions lib/src/utils/number_system_utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,36 @@ class NumberSystemUtils {
bool usesInternationalNumberSystem,
num? val, {
int decimalPlaces = 2,
bool isCompact = true,
int decimalPlacesForInternational = 1,
}) =>
usesInternationalNumberSystem
? _parseAsInternational(val ?? 0,
decimalPlaces: decimalPlacesForInternational)
: _parseAsIndian(val ?? 0, decimalPlaces: decimalPlaces);
decimalPlaces: decimalPlacesForInternational,
isCompact: isCompact)
: _parseAsIndian(
val ?? 0,
decimalPlaces: decimalPlaces,
isCompact: isCompact,
);

String _parseAsInternational(num val, {int decimalPlaces = 0}) {
String _parseAsInternational(num val,
{int decimalPlaces = 0, bool isCompact = true}) {
return formatValue(
val.toDouble(),
locale: 'en_US',
decimalPlaces: decimalPlaces,
isCompact: isCompact,
);
}

String _parseAsIndian(num val, {int decimalPlaces = 0}) {
String _parseAsIndian(num val,
{int decimalPlaces = 0, bool isCompact = true}) {
return formatValue(
val.toDouble(),
locale: 'en_IN',
decimalPlaces: decimalPlaces,
isCompact: isCompact,
);
}
}

0 comments on commit 78a5832

Please sign in to comment.