How to force decimals in flutter's Numberformat.compactCurreny?

Viewed 655

I'm trying to get a human comprehensive monetary value.

Being that value 100000 it returns 100K Being that value 100500 it returns 101K when I would like to get 100.5K

Note that I'm using the intl number format because I expect to be able to send in the locale and get the proper parsing of dots and commas for different regions

Here's the snipped of code I'm running:

  double amount = 100500;
  String currency = "EUR";
  String locale = "en-US";

  NumberFormat.compactCurrency(
    locale: locale,
    name: currency,
    symbol: "",
    decimalDigits: 1,
  ).format(amount);

Seems that calling for compactCurrency basically compacts the number to a 3 character string so it ceils/floors the value instead of showing the decimals corresponding to it

Is there any solution to this behavior? I've seen the option of creating a new locale setting but that's not really an elegant solution as this is used to display different patterns per locale and would have to maintain the separators logic and everything.

0 Answers
Related