toKMB method

String toKMB()

Implementation

String toKMB() {
  if (this < 1000) return toString();
  if (this < 100000) return "${(this / 1000).toStringAsFixed(1)} K";
  if (this < 1000000) return "${(this / 1000).toStringAsFixed(0)} K";
  if (this < 1000000000) return "${(this / 1000000).toStringAsFixed(1)} M";
  return "${(this / 1000000000).toStringAsFixed(1)} B";
}