number static method

String number(
  1. double value
)

Formats a single value for speech: integers drop the decimal, and fractional values trim trailing zeros (so 40.0 reads as "40").

Implementation

static String number(double value) {
  if (value == value.roundToDouble()) return '${value.round()}';
  var text = value.toStringAsFixed(2);
  while (text.endsWith('0')) {
    text = text.substring(0, text.length - 1);
  }
  if (text.endsWith('.')) text = text.substring(0, text.length - 1);
  return text;
}