toCompactCurrency method

String toCompactCurrency({
  1. Currency? currency,
  2. String? code,
  3. bool withPattern = true,
})

Sample: 1234.5.toCompactCurrency(code: 'EUR') => 1K € Sample (locale 'en_US'): 1234.5.toCompactCurrency(code: 'EUR', withPattern: false) => €1K

Implementation

String toCompactCurrency(
    {Currency? currency, String? code, bool withPattern = true}) {
  fn(Currency? currency, String? locale) => NumberFormat.compactCurrency(
        locale: locale,
        symbol: '',
        decimalDigits: currency?.decimalDigits,
      );
  return _convert(fn,
      currency: currency, code: code, withPattern: withPattern);
}