show method
Returns the money representation in order to show it in the UI.
It be possible to utilize ‘k
representation’ (for example, “10000” is
rewritten as “10k”). Also, it be possible to change the locale
parameter.
(Using 'it_IT'
locale, for example, it will write the money
representation using a no-break space
between the amount and the currency).
Implementation
String show({
bool k = false,
String? locale,
}) {
final int decimalDigits = amount % 1 == 0 ? 0 : 1;
final String value = NumberFormat.currency(
decimalDigits: k ? decimalDigits : currency.exponent,
locale: locale,
name: currency.alphabetic,
symbol: currency.symbol,
).format(k ? amount / 1000 : amount);
return k ? '$value k' : value;
}