From 4b3034587ce02ac7aeb99f7e0afb8ece6123e192 Mon Sep 17 00:00:00 2001 From: "DESKTOP-I3JPKHK\\wy" <1111> Date: Sat, 29 Nov 2025 15:33:12 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96formatBytes=E5=87=BD=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/app_upgrade_simple.dart | 2 +- lib/core/upgrade_utils.dart | 14 ++++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/lib/app_upgrade_simple.dart b/lib/app_upgrade_simple.dart index f49ca61..c9bb277 100644 --- a/lib/app_upgrade_simple.dart +++ b/lib/app_upgrade_simple.dart @@ -1006,7 +1006,7 @@ mixin _UpgradeDialogLogic on State { context, icon: Icons.file_download, label: '新版体积', - value: formatBytes(info.apkSize!), + value: UpgradeUtils.formatBytes(info.apkSize!), colorScheme: colorScheme, ), ), diff --git a/lib/core/upgrade_utils.dart b/lib/core/upgrade_utils.dart index e760888..e56cc8b 100644 --- a/lib/core/upgrade_utils.dart +++ b/lib/core/upgrade_utils.dart @@ -1,8 +1,10 @@ -String formatBytes(int bytes) { - if (bytes < 1024) return '$bytes B'; - if (bytes < 1024 * 1024) return '${(bytes / 1024).toStringAsFixed(2)} KB'; - if (bytes < 1024 * 1024 * 1024) { - return '${(bytes / (1024 * 1024)).toStringAsFixed(2)} MB'; +class UpgradeUtils { + static String formatBytes(int bytes) { + if (bytes < 1024) return '$bytes B'; + if (bytes < 1024 * 1024) return '${(bytes / 1024).toStringAsFixed(2)} KB'; + if (bytes < 1024 * 1024 * 1024) { + return '${(bytes / (1024 * 1024)).toStringAsFixed(2)} MB'; + } + return '${(bytes / (1024 * 1024 * 1024)).toStringAsFixed(2)} GB'; } - return '${(bytes / (1024 * 1024 * 1024)).toStringAsFixed(2)} GB'; }