Skip to content

Commit 5ca46ee

Browse files
Kapdroidsinghtaranjeet
authored andcommitted
refactor(currency-utils): formatting to drop unnecessary trailing zeros
Signed-off-by: Kapdroid <[email protected]>
1 parent d0c985a commit 5ca46ee

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

lib/src/utils/currency/helper.dart

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,10 @@ class CurrencyUtil {
4242
final normalizedValue = roundNumber(inputValue);
4343
final compactResult = _getCompactFormatResult(normalizedValue);
4444
final compactValue = compactResult.value;
45-
final int usedDecimalDigits = (passedDecimalDigits ??
46-
decimalDigits ??
47-
(((useCompact && compactValue % 1 != 0) || inputValue % 1 != 0)
48-
? 2
49-
: 0));
45+
final int usedDecimalDigits =
46+
((useCompact && compactValue % 1 != 0) || inputValue % 1 != 0)
47+
? (passedDecimalDigits ?? decimalDigits ?? 2)
48+
: 0;
5049
final localFormatter = locale.getCurrencyFormatNoSymbol(usedDecimalDigits);
5150

5251
try {
@@ -88,7 +87,9 @@ class CurrencyUtil {
8887

8988
String getFormattedInrDouble(num amount, {bool? compact}) =>
9089
formatNumber(amount, compact: compact);
90+
9191
String getFormattedInrInt(num amount) => formatCurrency(amount);
92+
9293
String getFormattedIntDouble2Places(num amount, {bool? compact}) =>
9394
formatNumber(amount, compact: compact, passedDecimalDigits: 2);
9495

0 commit comments

Comments
 (0)