toCurrency method
String
toCurrency({
- CurrencyCountry country = CurrencyCountry.ID,
- bool usingSymbol = true,
- int decimalDigits = 0,
Converts the number into a currency format using CurrencyCountry.
Example:
15000.0.toCurrency(country: CurrencyCountry.US); // "$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(safe()).trim();
}