formatSessionBytes function

String formatSessionBytes(
  1. int bytes
)

Human-readable byte count for the backstop error (GiB/MB granularity).

Implementation

String formatSessionBytes(int bytes) {
  if (bytes >= (1 << 30)) {
    return '${(bytes / (1 << 30)).toStringAsFixed(1)} GiB';
  }
  if (bytes >= (1 << 20)) {
    return '${(bytes / (1 << 20)).toStringAsFixed(1)} MB';
  }
  return '$bytes bytes';
}