getStorageStringFromByte static method
Implementation
static String getStorageStringFromByte(int bytes) {
double b = bytes.toDouble(); //1024
double k = bytes / 1024; //1
double m = k / 1024; //0.001
double g = m / 1024; //...
double t = g / 1024; //...
if (t >= 1) {
return "${t.toStringAsFixed(2)} TB";
} else if (g >= 1) {
return "${g.toStringAsFixed(2)} GB";
} else if (m >= 1) {
return "${m.toStringAsFixed(2)} MB";
} else if (k >= 1) {
return "${k.toStringAsFixed(2)} KB";
} else {
return "${b.toStringAsFixed(2)} Bytes";
}
}