toString method
4GB, 1.5GB, 384KB: the largest unit the size reaches, to one
decimal place, which is how the diagnostics print it.
Implementation
@override
String toString() {
for (final String unit in const <String>['TB', 'GB', 'MB', 'KB']) {
final int scale = _units[unit]!;
if (bytes >= scale) {
final String n = (bytes / scale).toStringAsFixed(1);
return '${n.endsWith('.0') ? n.substring(0, n.length - 2) : n}$unit';
}
}
return '${bytes}B';
}