formatNumber method

String formatNumber(
  1. double numericValue
)

Implementation

String formatNumber(double numericValue) {
  if (numericValue == numericValue.truncateToDouble())
    return numericValue.toInt().toString();
  if (numericValue.abs() < 0.01 || numericValue.abs() >= 10000)
    return numericValue.toStringAsExponential(1);
  return numericValue.toStringAsFixed(2);
}