NumberFormat.simpleCurrency constructor
Creates a NumberFormat for currencies, using the simple symbol for the currency if one is available (e.g. $, €), so it should only be used if the short currency symbol will be unambiguous.
If locale
is not specified, it will use the current default locale.
If name
is specified, the currency with that ISO 4217 name will be used.
Otherwise we will use the default currency name for the current locale. We
will assume that the symbol for this is well known in the locale and
unambiguous. If you format CAD in an en_US locale using this format it
will display as "$", which may be confusing to the user.
If decimalDigits
is specified, numbers will format with that many digits
after the decimal place. If it's not, they will use the default for the
currency in name
, and the default currency for locale
if the currency
name is not specified. e.g.
new NumberFormat.simpleCurrency(name: 'USD', decimalDigits: 7)
will format with 7 decimal digits, because that's what we asked for. But
new NumberFormat.simpleCurrency(locale: 'en_US', name: 'JPY')
will format with zero, because that's the default for JPY, and the
currency's default takes priority over the locale's default.
new NumberFormat.simpleCurrency(locale: 'en_US')
will format with two, which is the default for that locale.
Implementation
factory NumberFormat.simpleCurrency(
{String locale, String name, int decimalDigits}) {
return new NumberFormat._forPattern(locale, (x) => x.CURRENCY_PATTERN,
name: name,
computeCurrencySymbol: (format) =>
_simpleCurrencySymbols[format.currencyName] ?? format.currencyName,
decimalDigits: decimalDigits,
isForCurrency: true);
}