优化formatBytes函数
This commit is contained in:
parent
7bc09696af
commit
4b3034587c
|
|
@ -1006,7 +1006,7 @@ mixin _UpgradeDialogLogic<T extends StatefulWidget> on State<T> {
|
|||
context,
|
||||
icon: Icons.file_download,
|
||||
label: '新版体积',
|
||||
value: formatBytes(info.apkSize!),
|
||||
value: UpgradeUtils.formatBytes(info.apkSize!),
|
||||
colorScheme: colorScheme,
|
||||
),
|
||||
),
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
String formatBytes(int bytes) {
|
||||
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) {
|
||||
|
|
@ -6,3 +7,4 @@ String formatBytes(int bytes) {
|
|||
}
|
||||
return '${(bytes / (1024 * 1024 * 1024)).toStringAsFixed(2)} GB';
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue