How to change the pattern of compact formatting in NumberFormat class of intl package of flutter?

20 Views Asked by At

I am using Flutter with the intl package.

I need to format some currencies in the compact version but not for all locales i have a good result.
In particular, i neel something like this:

  • 1234 -> 1,23K $ / 1,23K €

  • 123456 -> 123,4K $ / 123,4K €

  • 1234567 -> 1,23M $ / 1,23M €

So I need compact the values with K or M, also by specify the decimal digits if possible.
The problem is that by using the "en_US" locale the result is quite good (except for the decimal digits) but using other locale like "it_IT" (i'm italian) the result is so different:

NumberFormat.compactSimpleCurrency(locale: "en_US") -> $ 123K
NumberFormat.compactSimpleCurrency(locale: "it_IT") -> 123456 €

NumberFormat.compactSimpleCurrency(locale: "en_US") -> $ 1,23M
NumberFormat.compactSimpleCurrency(locale: "it_IT") -> 1,22 Mio €

Why for en_US use K and for it_IT use nothing but to delete the thousand dot? Can i make both with K? Why for million in en_US use M and for it_IT use Mio? Can I make both M? And also, is possible to choose where to put the currency symbol (prefix/sufffix)?

The only thing that I saw was that.i can pass a custom Pattern to NumberFormat but I haven't found any way to customize "compact" version of it.

0

There are 0 best solutions below