Index: runtime/bin/vmservice/client/lib/src/app/utils.dart |
diff --git a/runtime/bin/vmservice/client/lib/src/app/utils.dart b/runtime/bin/vmservice/client/lib/src/app/utils.dart |
index 95dc6b59ffc91ddf4580b02e8bd9fafd0365ca85..a53bd59465ceb659d5c6b001ace7b1e4997873d0 100644 |
--- a/runtime/bin/vmservice/client/lib/src/app/utils.dart |
+++ b/runtime/bin/vmservice/client/lib/src/app/utils.dart |
@@ -73,22 +73,23 @@ class Utils { |
} |
static String formatSize(int bytes) { |
+ const int digits = 2; |
const int bytesPerKB = 1024; |
- const int bytesPerMB = 1024 * bytesPerKB; |
- const int bytesPerGB = 1024 * bytesPerMB; |
- const int bytesPerTB = 1024 * bytesPerGB; |
- |
- if (bytes < bytesPerKB) { |
- return "${bytes}B"; |
- } else if (bytes < bytesPerMB) { |
- return "${(bytes / bytesPerKB).round()}KB"; |
- } else if (bytes < bytesPerGB) { |
- return "${(bytes / bytesPerMB).round()}MB"; |
- } else if (bytes < bytesPerTB) { |
- return "${(bytes / bytesPerGB).round()}GB"; |
- } else { |
- return "${(bytes / bytesPerTB).round()}TB"; |
- } |
+ const int bytesPerMB = 1024 * bytesPerKB; |
+ const int bytesPerGB = 1024 * bytesPerMB; |
+ const int bytesPerTB = 1024 * bytesPerGB; |
+ |
+ if (bytes < bytesPerKB) { |
+ return "${bytes}B"; |
+ } else if (bytes < bytesPerMB) { |
+ return "${(bytes / bytesPerKB).toStringAsFixed(digits)}KB"; |
+ } else if (bytes < bytesPerGB) { |
+ return "${(bytes / bytesPerMB).toStringAsFixed(digits)}MB"; |
+ } else if (bytes < bytesPerTB) { |
+ return "${(bytes / bytesPerGB).toStringAsFixed(digits)}GB"; |
+ } else { |
+ return "${(bytes / bytesPerTB).toStringAsFixed(digits)}TB"; |
+ } |
} |
static String formatTime(double time) { |