formatToolSize function

String formatToolSize(
  1. int bytes
)

Formats a byte count as a human-readable size (pi's formatSize).

Implementation

String formatToolSize(int bytes) {
  if (bytes < 1024) return '${bytes}B';
  if (bytes < 1024 * 1024) {
    return '${(bytes / 1024).toStringAsFixed(1)}KB';
  }
  return '${(bytes / (1024 * 1024)).toStringAsFixed(1)}MB';
}