From b922428c407a455a77b80ca223561d9e1bf7b933 Mon Sep 17 00:00:00 2001 From: Junyuan Feng Date: Sun, 2 Jan 2022 19:26:00 +0800 Subject: [PATCH] Fix mem progress display percent. --- lib/data/res/build_data.dart | 9 ++++----- lib/view/page/server/detail.dart | 8 ++++++-- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/lib/data/res/build_data.dart b/lib/data/res/build_data.dart index 56d4e89e..12f79cd6 100644 --- a/lib/data/res/build_data.dart +++ b/lib/data/res/build_data.dart @@ -2,9 +2,8 @@ class BuildData { static const String name = "ToolBox"; - static const int build = 68; - static const String engine = - "Flutter 2.8.1 • channel stable • https://github.com/flutter/flutter.git\nFramework • revision 77d935af4d (2 weeks ago) • 2021-12-16 08:37:33 -0800\nEngine • revision 890a5fca2e\nTools • Dart 2.15.1\n"; - static const String buildAt = "2022-01-02 14:53:09.769990"; - static const int modifications = 3; + static const int build = 69; + static const String engine = "Flutter 2.8.1 • channel stable • https://github.com/flutter/flutter.git\nFramework • revision 77d935af4d (2 weeks ago) • 2021-12-16 08:37:33 -0800\nEngine • revision 890a5fca2e\nTools • Dart 2.15.1\n"; + static const String buildAt = "2022-01-02 19:20:43.964228"; + static const int modifications = 2; } diff --git a/lib/view/page/server/detail.dart b/lib/view/page/server/detail.dart index be4ee9ee..14cc2334 100644 --- a/lib/view/page/server/detail.dart +++ b/lib/view/page/server/detail.dart @@ -191,7 +191,11 @@ class _ServerDetailPageState extends State for (; value / 1024 > 1 && squareTimes < 3; squareTimes++) { value /= 1024; } - return '${value.toStringAsFixed(1)} ${suffix[squareTimes]}'; + var finalValue = value.toStringAsFixed(1); + if (finalValue.endsWith('.0')) { + finalValue = finalValue.replaceFirst('.0', ''); + } + return '$finalValue ${suffix[squareTimes]}'; } Widget _buildMemView(ServerStatus ss) { @@ -231,7 +235,7 @@ class _ServerDetailPageState extends State // memory.total == 1: failed to get mem, now mem = [emptyMemory] which is initial value. value: ss.memory.total == 1 ? 0 - : ss.memory.cache / ss.memory.total, + : ss.memory.cache / (ss.memory.total - ss.memory.used), backgroundColor: progressColor.resolve(context), color: pColor.withAlpha(77), ),