toPriceAmount method
Tries to format the current String
to price amount.
You can optionally pass the currencySymbol
to append a symbol to the formatted text.
Example
String price = '1234567';
String formattedPrice = foo1.toPriceAmount(currencySymbol: '€'); // returns '12.345,67 €'
Implementation
String toPriceAmount({String? currencySymbol, string? locale}) {
if (isBlank) {
return blankIfNull;
}
locale ??= platformLocaleCode;
try {
var f = NumberFormat.currency(locale: locale, symbol: currencySymbol);
return f.format(this);
} catch (e) {
return blankIfNull;
}
}