toBKMG method

String toBKMG()

Implementation

String toBKMG() {
  if (this <= 0) return "0 B";
  const List<String> suffixes = <String>["B", "KB", "MB", "GB"];
  final int i = (log(this) / log(1024)).floor();
  return "${(this / pow(1024, i)).toStringAsFixed(1)} ${suffixes[i]}";
}