formatBytes function
Implementation
String formatBytes(num bytes) {
const units = ['B', 'kB', 'MB', 'GB'];
var value = bytes.toDouble();
var unit = 0;
while (value >= 1024 && unit < units.length - 1) {
value /= 1024;
unit++;
}
return '${value.toStringAsFixed(unit == 0 ? 0 : 1)} ${units[unit]}';
}