Fix & Optimize

- fix ping when results is empty
- optimize ping speed
This commit is contained in:
Junyuan Feng
2022-05-03 20:26:00 +08:00
parent 5c59833233
commit 52b82af52c
3 changed files with 23 additions and 17 deletions

View File

@@ -354,7 +354,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CURRENT_PROJECT_VERSION = 118;
CURRENT_PROJECT_VERSION = 119;
DEVELOPMENT_TEAM = BA88US33G6;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist;
@@ -362,7 +362,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.0.118;
MARKETING_VERSION = 1.0.119;
PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
@@ -484,7 +484,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CURRENT_PROJECT_VERSION = 118;
CURRENT_PROJECT_VERSION = 119;
DEVELOPMENT_TEAM = BA88US33G6;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist;
@@ -492,7 +492,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.0.118;
MARKETING_VERSION = 1.0.119;
PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
@@ -508,7 +508,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CURRENT_PROJECT_VERSION = 118;
CURRENT_PROJECT_VERSION = 119;
DEVELOPMENT_TEAM = BA88US33G6;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist;
@@ -516,7 +516,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.0.118;
MARKETING_VERSION = 1.0.119;
PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";

View File

@@ -2,8 +2,9 @@
class BuildData {
static const String name = "ServerBox";
static const int build = 118;
static const String engine = "Flutter 2.10.4 • channel stable • https://github.com/flutter/flutter.git\nFramework • revision c860cba910 (6 weeks ago) • 2022-03-25 00:23:12 -0500\nEngine • revision 57d3bac3dd\nTools • Dart 2.16.2 • DevTools 2.9.2\n";
static const String buildAt = "2022-05-03 12:05:15.250795";
static const int modifications = 4;
static const int build = 119;
static const String engine =
"Flutter 2.10.4 • channel stable • https://github.com/flutter/flutter.git\nFramework • revision c860cba910 (6 weeks ago) • 2022-03-25 00:23:12 -0500\nEngine • revision 57d3bac3dd\nTools • Dart 2.16.2 • DevTools 2.9.2\n";
static const String buildAt = "2022-05-03 12:06:26.688732";
static const int modifications = 0;
}

View File

@@ -77,6 +77,9 @@ class _PingPageState extends State<PingPage>
String _buildPingSummary(PingResult result) {
final ip = result.ip ?? 'unkown';
if (result.results == null || result.results!.isEmpty) {
return '$ip - no results';
}
final ttl = result.results?.first.ttl ?? 'unkown';
final loss = result.statistic?.loss ?? 'unkown';
final min = result.statistic?.min ?? 'unkown';
@@ -91,14 +94,15 @@ class _PingPageState extends State<PingPage>
showSnackBar(context, const Text('Please input a target'));
return;
}
for (var si in locator<ServerProvider>().servers) {
if (si.client == null) {
continue;
await Future.wait(locator<ServerProvider>().servers.map((e) async {
if (e.client == null) {
return;
}
final result = await si.client!.run('ping -c 3 $target').string;
_results.add(PingResult.parse(si.info.name, result));
final result = await e.client!.run('ping -c 3 $target').string;
_results.add(PingResult.parse(e.info.name, result));
setState(() {});
}
}));
}
Widget _buildControl() {
@@ -115,7 +119,7 @@ class _PingPageState extends State<PingPage>
foregroundColor: MaterialStateProperty.all(primaryColor)),
child: Row(
children: const [
Icon(Icons.stop),
Icon(Icons.delete),
SizedBox(
width: 7,
),
@@ -124,6 +128,7 @@ class _PingPageState extends State<PingPage>
),
onPressed: () {
_results.clear();
setState(() {});
},
),
TextButton(