number static method

String number(
  1. num value
)

Implementation

static String number(num value) {
  if (value is int) return "$value";
  final double asDouble = value.toDouble();
  if (asDouble == asDouble.roundToDouble() && asDouble.abs() < 1000000000) return "${asDouble.round()}";
  String text = asDouble.toStringAsFixed(6);
  while (text.contains(".") && (text.endsWith("0") || text.endsWith("."))) {
    text = text.substring(0, text.length - 1);
  }
  return text.isEmpty ? "0" : text;
}