noTrailing method
remove trailing zeros from the number ex: 15.00 => 15 if fractionDigits is specified ex noTrailing(2) 15.5 => 15.50 15.500 => 15.50 15.00 => 15.00
Implementation
String noTrailing({
int? fractionDigits,
bool grouping = true,
String? locale,
}) {
if (this == null) return '';
var format = grouping ? '#,##0.' : '#.';
if (fractionDigits == null) {
format += '#############';
} else {
format += List.filled(fractionDigits, '0').join();
}
return formatWith(NumberFormat(format, locale));
}