formatBytes static method

String formatBytes(
  1. int bytes
)

Format bytes text

Implementation

static String formatBytes(int bytes) => switch (bytes) {
  int bytes when bytes < 0 => '-1 $_bytes',
  int bytes when bytes <= _kilobyteAsByte => '$bytes $_bytes',
  int bytes when bytes <= _megabyteAsByte =>
    '${_formatDouble(bytes / _kilobyteAsByte)} $_kiloBytes',
  _ => '${_formatDouble(bytes / _megabyteAsByte)} $_megaBytes',
};