|
@@ -24,3 +24,17 @@ String formatBytes(int bytes, [int decimals = 2]) {
|
|
final int i = (log(bytes) / log(k)).floor();
|
|
final int i = (log(bytes) / log(k)).floor();
|
|
return ((bytes / pow(k, i)).toStringAsFixed(dm)) + ' ' + storageUnits[i];
|
|
return ((bytes / pow(k, i)).toStringAsFixed(dm)) + ' ' + storageUnits[i];
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+num convertUsedSpaceInBytesToGB(int bytes) {
|
|
|
|
+ const tenGBinBytes = 10737418240;
|
|
|
|
+ int fractionDigits = 0;
|
|
|
|
+ if (bytes < tenGBinBytes) {
|
|
|
|
+ fractionDigits = 1;
|
|
|
|
+ }
|
|
|
|
+ num bytesInGB =
|
|
|
|
+ num.parse((bytes / (pow(1024, 3))).toStringAsFixed(fractionDigits));
|
|
|
|
+ if (fractionDigits == 1 && bytesInGB.remainder(1) == 0) {
|
|
|
|
+ bytesInGB = bytesInGB.toInt();
|
|
|
|
+ }
|
|
|
|
+ return bytesInGB;
|
|
|
|
+}
|