Fix mem progress display percent.

This commit is contained in:
Junyuan Feng
2022-01-02 19:26:00 +08:00
parent e08f37fedc
commit b922428c40
2 changed files with 10 additions and 7 deletions

View File

@@ -2,9 +2,8 @@
class BuildData { class BuildData {
static const String name = "ToolBox"; static const String name = "ToolBox";
static const int build = 68; static const int build = 69;
static const String engine = 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";
"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 String buildAt = "2022-01-02 14:53:09.769990"; static const int modifications = 2;
static const int modifications = 3;
} }

View File

@@ -191,7 +191,11 @@ class _ServerDetailPageState extends State<ServerDetailPage>
for (; value / 1024 > 1 && squareTimes < 3; squareTimes++) { for (; value / 1024 > 1 && squareTimes < 3; squareTimes++) {
value /= 1024; 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) { Widget _buildMemView(ServerStatus ss) {
@@ -231,7 +235,7 @@ class _ServerDetailPageState extends State<ServerDetailPage>
// memory.total == 1: failed to get mem, now mem = [emptyMemory] which is initial value. // memory.total == 1: failed to get mem, now mem = [emptyMemory] which is initial value.
value: ss.memory.total == 1 value: ss.memory.total == 1
? 0 ? 0
: ss.memory.cache / ss.memory.total, : ss.memory.cache / (ss.memory.total - ss.memory.used),
backgroundColor: progressColor.resolve(context), backgroundColor: progressColor.resolve(context),
color: pColor.withAlpha(77), color: pColor.withAlpha(77),
), ),