formatPercentage function
Formats a value
as a percentage 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 formatPercentage({
num? value,
String? locale = 'en_US',
String? pattern = "#,##0.##",
int? minimumFractionDigits,
int? maximumFractionDigits,
}) {
if (value == null) return '';
final number = formatDecimal(
minimumFractionDigits: minimumFractionDigits,
maximumFractionDigits: maximumFractionDigits,
value: value * 100,
pattern: pattern,
locale: locale,
);
return '$number%';
}