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