formatCurrency function
Formats a value
as a currency string using the given locale
and symbol
.
minimumFractionDigits
and maximumFractionDigits
can be used to specify
the minimum and maximum number of decimal places to display.
Implementation
String formatCurrency({
num? value,
String? locale = 'en_US',
String symbol = 'USD',
int? minimumFractionDigits,
int? maximumFractionDigits,
}) {
if (value == null) return '';
final formatter = getCurrencyNumberFormat(
minimumFractionDigits: minimumFractionDigits,
maximumFractionDigits: maximumFractionDigits,
symbol: symbol,
locale: locale,
value: value,
);
return formatter.format(value);
}