formatBytes static method

String formatBytes(
  1. int bytes
)

Format bytes text

Implementation

static String formatBytes(int bytes) {
  if (bytes < 0) {
    return '-1 B';
  }
  if (bytes <= _kilobyteAsByte) {
    return '$bytes B';
  }
  if (bytes <= _megabyteAsByte) {
    return '${_formatDouble(bytes / _kilobyteAsByte)} kB';
  }

  return '${_formatDouble(bytes / _megabyteAsByte)} MB';
}