Skip to content

Commit

Permalink
fix: net dev (#234 #236)
Browse files Browse the repository at this point in the history
  • Loading branch information
lollipopkit committed Dec 15, 2023
1 parent 54c75ec commit f10c5b9
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions lib/data/model/server/net_speed.dart
Original file line number Diff line number Diff line change
Expand Up @@ -105,14 +105,18 @@ List<NetSpeedPart> parseNetSpeed(String raw, int time) {
}

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 = BigInt.parse(bytes.first);
final bytesOut = BigInt.parse(bytes[8]);
results.add(NetSpeedPart(device, bytesIn, bytesOut, time));
for (final item in split.sublist(2)) {
try {
final data = item.trim().split(':');
final device = data.first;
final bytes = data.last.trim().split(' ');
bytes.removeWhere((element) => element == '');
final bytesIn = BigInt.parse(bytes.first);
final bytesOut = BigInt.parse(bytes[8]);
results.add(NetSpeedPart(device, bytesIn, bytesOut, time));
} catch (_) {
continue;
}
}
return results;
}
Expand Down

0 comments on commit f10c5b9

Please sign in to comment.