An open-source cross-platform alternative to AirDrop
feat: change file size calculation to decimal
Tien Do Namfdec91960b77
diff --git a/packages/localsend_isolates/lib/util/file_size_helper.dart b/packages/localsend_isolates/lib/util/file_size_helper.dartindex def59805..4e5b577a 100644--- a/packages/localsend_isolates/lib/util/file_size_helper.dart+++ b/packages/localsend_isolates/lib/util/file_size_helper.dart@@ -1,14 +1,15 @@extension IntFileSize on int {/// Converts the integer representing bytes to a readable string+ /// using decimal units (1 KB = 1000 B).String get asReadableFileSize {- if (this < 1024) {+ if (this < 1000) {return '$this B';- } else if (this < 1024 * 1024) {- return '${(this / 1024).toStringAsFixed(1)} KB';- } else if (this < 1024 * 1024 * 1024) {- return '${(this / (1024 * 1024)).toStringAsFixed(1)} MB';+ } else if (this < 1000 * 1000) {+ return '${(this / 1000).toStringAsFixed(1)} KB';+ } else if (this < 1000 * 1000 * 1000) {+ return '${(this / (1000 * 1000)).toStringAsFixed(1)} MB';} else {- return '${(this / (1024 * 1024 * 1024)).toStringAsFixed(1)} GB';+ return '${(this / (1000 * 1000 * 1000)).toStringAsFixed(1)} GB';}}}