asAbbreviated method

String asAbbreviated()

Implementation

String asAbbreviated() {
  if (this < 1000) return toStringAsFixed(3);
  if (this >= 1e18) return toStringAsExponential(3);
  final s = NumberFormat("#,###", "en_US").format(this).split(",");
  const suffixes = ["K", "M", "B", "T", "Q"];
  return "${s[0]}.${s[1]}${suffixes[s.length - 2]}";
}