toCurrency method
String
toCurrency({
- CurrencyCountry country = CurrencyCountry.ID,
- bool usingSymbol = true,
- int decimalDigits = 0,
Converts the integer into a formatted currency string using CurrencyCountry.
Example:
15000.toCurrency(country: CurrencyCountry.US); // $15,000
15000.toCurrency(country: CurrencyCountry.JP); // ¥15,000
Implementation
String toCurrency({
CurrencyCountry country = CurrencyCountry.ID,
bool usingSymbol = true,
int decimalDigits = 0,
}) {
final formatter = NumberFormat.currency(
locale: country.locale,
symbol: usingSymbol ? country.symbol : '',
decimalDigits: decimalDigits,
);
return formatter.format(this ?? 0).trim();
}