NumberFormat.simpleCurrency constructor Null safety

  1. {String? locale,
  2. String? name,
  3. int? decimalDigits}

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. NumberFormat.simpleCurrency(name: 'USD', decimalDigits: 7) will format with 7 decimal digits, because that's what we asked for. But 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. NumberFormat.simpleCurrency(locale: 'en_US') will format with two, which is the default for that locale.


factory NumberFormat.simpleCurrency(
    {String? locale, String? name, int? decimalDigits}) {
  return NumberFormat._forPattern(locale, (x) => x.CURRENCY_PATTERN,
      name: name,
      decimalDigits: decimalDigits,
      lookupSimpleCurrencySymbol: true,
      isForCurrency: true);