formatBytes function
Implementation
String formatBytes(int bytes) {
if (bytes < 1024 * 1024) {
var kb = bytes / 1024;
return "${kb.toStringAsFixed(2)} KB";
} else {
var mb = bytes / (1024 * 1024);
if (mb < 1024) {
return "${mb.toStringAsFixed(2)} MB";
} else {
var gb = mb / 1024;
return "${gb.toStringAsFixed(2)} GB";
}
}
}