fix: netspeed bytes too large

This commit is contained in:
lollipopkit
2023-02-02 12:04:01 +08:00
parent c47e24ac5b
commit 469b9fe8cd
4 changed files with 19 additions and 19 deletions

View File

@@ -2,9 +2,9 @@ import 'package:toolbox/core/extension/numx.dart';
class NetSpeedPart {
String device;
int bytesIn;
int bytesOut;
int time;
BigInt bytesIn;
BigInt bytesOut;
BigInt time;
NetSpeedPart(this.device, this.bytesIn, this.bytesOut, this.time);
}
@@ -26,7 +26,7 @@ class NetSpeed {
_now = newOne;
}
int get timeDiff => _now[0].time - _old[0].time;
BigInt get timeDiff => _now[0].time - _old[0].time;
String speedIn({String? device}) {
if (_old[0].device == '' || _now[0].device == '') return '0kb/s';
@@ -65,15 +65,15 @@ List<NetSpeedPart> parseNetSpeed(String raw) {
return [];
}
final time = int.parse(split[split.length - 1]);
final time = BigInt.parse(split[split.length - 1]);
final results = <NetSpeedPart>[];
for (final item in split.sublist(2, split.length - 1)) {
final data = item.trim().split(':');
final device = data.first;
final bytes = data.last.trim().split(' ');
bytes.removeWhere((element) => element == '');
final bytesIn = int.parse(bytes.first);
final bytesOut = int.parse(bytes[8]);
final bytesIn = BigInt.parse(bytes.first);
final bytesOut = BigInt.parse(bytes[8]);
results.add(NetSpeedPart(device, bytesIn, bytesOut, time));
}
return results;

View File

@@ -2,9 +2,9 @@
class BuildData {
static const String name = "ServerBox";
static const int build = 209;
static const int build = 210;
static const String engine =
"Flutter 3.7.0 • channel stable • https://github.com/flutter/flutter.git\nFramework • revision b06b8b2710 (9 days ago) • 2023-01-23 16:55:55 -0800\nEngine • revision b24591ed32\nTools • Dart 2.19.0 • DevTools 2.20.1\n";
static const String buildAt = "2023-02-01 23:33:10.191128";
static const int modifications = 2;
static const String buildAt = "2023-02-01 23:36:32.789406";
static const int modifications = 0;
}

View File

@@ -29,9 +29,9 @@ get initCpuStatus => CpuStatus(
);
get _initNetSpeedPart => NetSpeedPart(
'',
0,
0,
0,
BigInt.zero,
BigInt.zero,
BigInt.zero,
);
get initNetSpeed => NetSpeed(
[_initNetSpeedPart],