From f10c5b9ea8aee2c28eeaab41e7d3a40f68950ac5 Mon Sep 17 00:00:00 2001 From: lollipopkit Date: Fri, 15 Dec 2023 11:37:34 +0800 Subject: [PATCH] fix: net dev (#234 #236) --- lib/data/model/server/net_speed.dart | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/lib/data/model/server/net_speed.dart b/lib/data/model/server/net_speed.dart index 3ce4d3bfa..7a12a46c5 100644 --- a/lib/data/model/server/net_speed.dart +++ b/lib/data/model/server/net_speed.dart @@ -105,14 +105,18 @@ List parseNetSpeed(String raw, int time) { } final results = []; - 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; }