Optimzed & Flutter 3.3.4

This commit is contained in:
Junyuan Feng
2022-10-21 17:50:13 +08:00
parent 06302d7162
commit 7f1bd06422
19 changed files with 153 additions and 123 deletions

4
.fvm/fvm_config.json Normal file
View File

@@ -0,0 +1,4 @@
{
"flutterSdkVersion": "3.3.4",
"flavors": {}
}

1
.gitignore vendored
View File

@@ -48,3 +48,4 @@ app.*.map.json
/android/app/fjy.androidstudio.key
/release
test.dart
.fvm/flutter_sdk

9
.vscode/settings.json vendored Normal file
View File

@@ -0,0 +1,9 @@
{
"dart.flutterSdkPath": ".fvm/flutter_sdk",
"search.exclude": {
"**/.fvm": true
},
"files.watcherExclude": {
"**/.fvm": true
}
}

File diff suppressed because one or more lines are too long

View File

@@ -21,6 +21,6 @@
<key>CFBundleVersion</key>
<string>1.0</string>
<key>MinimumOSVersion</key>
<string>9.0</string>
<string>11.0</string>
</dict>
</plist>

View File

@@ -1,5 +1,5 @@
# Uncomment this line to define a global platform for your project
# platform :ios, '9.0'
# platform :ios, '11.0'
# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'

View File

@@ -40,13 +40,13 @@ EXTERNAL SOURCES:
SPEC CHECKSUMS:
countly_flutter: e245f94349d8adf306c22e60c10648c69aae7380
Flutter: 50d75fe2f02b26cc09d224853bb45737f8b3214a
Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854
flutter_native_splash: 52501b97d1c0a5f898d687f1646226c1f93c56ef
path_provider_ios: 14f3d2fd28c4fdb42f44e0f751d12861c43cee02
r_upgrade: 44d715c61914cce3d01ea225abffe894fd51c114
share_plus: 056a1e8ac890df3e33cb503afffaf1e9b4fbae68
url_launcher_ios: 839c58cdb4279282219f5e248c3321761ff3c4de
PODFILE CHECKSUM: aafe91acc616949ddb318b77800a7f51bffa2a4c
PODFILE CHECKSUM: ef19549a9bc3046e7bb7d2fab4d021637c0c58a3
COCOAPODS: 1.11.3

View File

@@ -339,7 +339,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SUPPORTED_PLATFORMS = iphoneos;
@@ -418,7 +418,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
@@ -467,7 +467,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SUPPORTED_PLATFORMS = iphoneos;

File diff suppressed because one or more lines are too long

View File

@@ -39,9 +39,9 @@ class NetSpeed {
String speedOut({String? device}) {
if (old[0].device == '' || now[0].device == '') return '0kb/s';
final idx = deviceIdx(device);
final speedInBytesPerSecond =
final speedOutBytesPerSecond =
(now[idx].bytesOut - old[idx].bytesOut) / timeDiff;
return buildStandardOutput(speedInBytesPerSecond);
return buildStandardOutput(speedOutBytesPerSecond);
}
int deviceIdx(String? device) {

View File

@@ -1,5 +1,4 @@
import 'package:dartssh2/dartssh2.dart';
import 'package:toolbox/data/model/server/server_connection_state.dart';
import 'package:toolbox/data/model/server/server_private_info.dart';
import 'package:toolbox/data/model/server/server_status.dart';
@@ -11,3 +10,5 @@ class ServerInfo {
ServerInfo(this.info, this.status, this.client, this.connectionState);
}
enum ServerConnectionState { disconnected, connecting, connected, failed }

View File

@@ -1 +0,0 @@
enum ServerConnectionState { disconnected, connecting, connected, failed }

View File

@@ -10,7 +10,6 @@ import 'package:toolbox/data/model/server/cpu_2_status.dart';
import 'package:toolbox/data/model/server/cpu_status.dart';
import 'package:toolbox/data/model/server/memory.dart';
import 'package:toolbox/data/model/server/net_speed.dart';
import 'package:toolbox/data/model/server/server_connection_state.dart';
import 'package:toolbox/data/model/server/disk_info.dart';
import 'package:toolbox/data/model/server/server.dart';
import 'package:toolbox/data/model/server/server_private_info.dart';
@@ -229,23 +228,9 @@ class ServerProvider extends BusyProvider {
/// lo: 45929941 269112 0 0 0 0 0 0 45929941 269112 0 0 0 0 0 0
/// eth0: 48481023 505772 0 0 0 0 0 0 36002262 202307 0 0 0 0 0 0
/// 1635752901
void _getNetSpeed(ServerPrivateInfo spi, String raw) {
Future<void> _getNetSpeed(ServerPrivateInfo spi, String raw) async {
final info = _servers.firstWhere((e) => e.info == spi);
final split = raw.split('\n');
final deviceCount = split.length - 3;
if (deviceCount < 1) return;
final time = int.parse(split[split.length - 1]);
final results = <NetSpeedPart>[];
for (int idx = 2; idx < deviceCount; idx++) {
final data = split[idx].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]);
results.add(NetSpeedPart(device, bytesIn, bytesOut, time));
}
info.status.netSpeed.update(results);
info.status.netSpeed.update(await compute(_parseNetSpeed, raw));
}
void _getSysVer(ServerPrivateInfo spi, String raw) {
@@ -256,51 +241,14 @@ class ServerProvider extends BusyProvider {
}
}
String _getCPUTemp(String type, String value) {
const noMatch = "/sys/class/thermal/thermal_zone*/type";
// Not support to get CPU temperature
if (value.contains(noMatch) ||
type.contains(noMatch) ||
value.isEmpty ||
type.isEmpty) {
return '';
}
final split = type.split('\n');
int idx = 0;
for (var item in split) {
if (item.contains(cpuTempReg)) {
break;
}
idx++;
}
final valueSplited = value.split('\n');
if (idx >= valueSplited.length) return '';
final temp = int.tryParse(valueSplited[idx].trim());
if (temp == null) return '';
return '${(temp / 1000).toStringAsFixed(1)}°C';
}
void _getCPU(
ServerPrivateInfo spi, String raw, String tempType, String tempValue) {
Future<void> _getCPU(ServerPrivateInfo spi, String raw, String tempType,
String tempValue) async {
final info = _servers.firstWhere((e) => e.info == spi);
final List<CpuStatus> cpus = [];
final cpus = await compute(_parseCPU, raw);
for (var item in raw.split('\n')) {
if (item == '') break;
final id = item.split(' ').first;
final matches = item.replaceFirst(id, '').trim().split(' ');
cpus.add(CpuStatus(
id,
int.parse(matches[0]),
int.parse(matches[1]),
int.parse(matches[2]),
int.parse(matches[3]),
int.parse(matches[4]),
int.parse(matches[5]),
int.parse(matches[6])));
}
if (cpus.isNotEmpty) {
info.status.cpu2Status.update(cpus, _getCPUTemp(tempType, tempValue));
info.status.cpu2Status
.update(cpus, await compute(_getCPUTemp, [tempType, tempValue]));
}
}
@@ -309,14 +257,11 @@ class ServerProvider extends BusyProvider {
raw.split('up ')[1].split(', ')[0];
}
void _getTcp(ServerPrivateInfo spi, String raw) {
Future<void> _getTcp(ServerPrivateInfo spi, String raw) async {
final info = _servers.firstWhere((e) => e.info == spi);
final lines = raw.split('\n');
final idx = lines.lastWhere((element) => element.startsWith('Tcp:'),
orElse: () => '');
if (idx != '') {
final vals = idx.split(numReg);
info.status.tcp = TcpStatus(vals[5].i, vals[6].i, vals[7].i, vals[8].i);
final status = await compute(_parseTcp, raw);
if (status != null) {
info.status.tcp = status;
}
}
@@ -335,24 +280,10 @@ class ServerProvider extends BusyProvider {
info.status.disk = list;
}
void _getMem(ServerPrivateInfo spi, String raw) {
Future<void> _getMem(ServerPrivateInfo spi, String raw) async {
final info = _servers.firstWhere((e) => e.info == spi);
final items = raw.split('\n').map((e) => memItemReg.firstMatch(e)).toList();
final total = int.parse(
items.firstWhere((e) => e?.group(1) == 'MemTotal:')?.group(2) ?? '1');
final free = int.parse(
items.firstWhere((e) => e?.group(1) == 'MemFree:')?.group(2) ?? '0');
final cached = int.parse(
items.firstWhere((e) => e?.group(1) == 'Cached:')?.group(2) ?? '0');
final available = int.parse(
items.firstWhere((e) => e?.group(1) == 'MemAvailable:')?.group(2) ??
'0');
info.status.memory = Memory(
total: total,
used: total - available,
free: free,
cache: cached,
avail: available);
final mem = await compute(_parseMem, raw);
info.status.memory = mem;
}
Future<String?> runSnippet(ServerPrivateInfo spi, Snippet snippet) async {
@@ -363,3 +294,96 @@ class ServerProvider extends BusyProvider {
.string;
}
}
Memory _parseMem(String raw) {
final items = raw.split('\n').map((e) => memItemReg.firstMatch(e)).toList();
final total = int.parse(
items.firstWhere((e) => e?.group(1) == 'MemTotal:')?.group(2) ?? '1');
final free = int.parse(
items.firstWhere((e) => e?.group(1) == 'MemFree:')?.group(2) ?? '0');
final cached = int.parse(
items.firstWhere((e) => e?.group(1) == 'Cached:')?.group(2) ?? '0');
final available = int.parse(
items.firstWhere((e) => e?.group(1) == 'MemAvailable:')?.group(2) ?? '0');
return Memory(
total: total,
used: total - available,
free: free,
cache: cached,
avail: available);
}
TcpStatus? _parseTcp(String raw) {
final lines = raw.split('\n');
final idx = lines.lastWhere((element) => element.startsWith('Tcp:'),
orElse: () => '');
if (idx != '') {
final vals = idx.split(numReg);
return TcpStatus(vals[5].i, vals[6].i, vals[7].i, vals[8].i);
}
return null;
}
List<CpuStatus> _parseCPU(String raw) {
final List<CpuStatus> cpus = [];
for (var item in raw.split('\n')) {
if (item == '') break;
final id = item.split(' ').first;
final matches = item.replaceFirst(id, '').trim().split(' ');
cpus.add(CpuStatus(
id,
int.parse(matches[0]),
int.parse(matches[1]),
int.parse(matches[2]),
int.parse(matches[3]),
int.parse(matches[4]),
int.parse(matches[5]),
int.parse(matches[6])));
}
return cpus;
}
String _getCPUTemp(List<String> segments) {
const noMatch = "/sys/class/thermal/thermal_zone*/type";
final type = segments[0];
final value = segments[1];
// Not support to get CPU temperature
if (value.contains(noMatch) ||
type.contains(noMatch) ||
value.isEmpty ||
type.isEmpty) {
return '';
}
final split = type.split('\n');
int idx = 0;
for (var item in split) {
if (item.contains(cpuTempReg)) {
break;
}
idx++;
}
final valueSplited = value.split('\n');
if (idx >= valueSplited.length) return '';
final temp = int.tryParse(valueSplited[idx].trim());
if (temp == null) return '';
return '${(temp / 1000).toStringAsFixed(1)}°C';
}
List<NetSpeedPart> _parseNetSpeed(String raw) {
final split = raw.split('\n');
final deviceCount = split.length - 3;
if (deviceCount < 1) return [];
final time = int.parse(split[split.length - 1]);
final results = <NetSpeedPart>[];
for (int idx = 2; idx < deviceCount; idx++) {
final data = split[idx].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]);
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 = 153;
static const int build = 154;
static const String engine =
"Flutter 3.0.1 • channel stable • https://github.com/flutter/flutter.git\nFramework • revision fb57da5f94 (12 days ago) • 2022-05-19 15:50:29 -0700\nEngine • revision caaafc5604\nTools • Dart 2.17.1 • DevTools 2.12.2\n";
static const String buildAt = "2022-05-31 22:16:25.670160";
static const int modifications = 1;
"Flutter 3.3.4 • channel stable • https://github.com/flutter/flutter.git\nFramework • revision eb6d86ee27 (2 weeks ago) • 2022-10-04 22:31:45 -0700\nEngine • revision c08d7d5efc\nTools • Dart 2.18.2 • DevTools 2.15.0\n";
static const String buildAt = "2022-10-21 17:29:42.809139";
static const int modifications = 9;
}

View File

@@ -99,7 +99,7 @@ class _PrivateKeyEditPageState extends State<PrivateKeyEditPage>
tooltip: s.save,
onPressed: () async {
final name = nameController.text;
final key = keyController.text;
final key = keyController.text.trim();
final pwd = pwdController.text;
if (name.isEmpty || key.isEmpty) {
showSnackBar(context, Text(s.fieldMustNotEmpty));

View File

@@ -9,7 +9,6 @@ import 'package:toolbox/core/route.dart';
import 'package:toolbox/core/utils.dart';
import 'package:toolbox/data/model/app/menu_item.dart';
import 'package:toolbox/data/model/server/server.dart';
import 'package:toolbox/data/model/server/server_connection_state.dart';
import 'package:toolbox/data/model/server/server_private_info.dart';
import 'package:toolbox/data/model/server/server_status.dart';
import 'package:toolbox/data/provider/server.dart';

View File

@@ -6,7 +6,7 @@ import 'package:toolbox/core/extension/numx.dart';
import 'package:toolbox/core/extension/stringx.dart';
import 'package:toolbox/core/route.dart';
import 'package:toolbox/core/utils.dart';
import 'package:toolbox/data/model/server/server_connection_state.dart';
import 'package:toolbox/data/model/server/server.dart';
import 'package:toolbox/data/model/server/server_private_info.dart';
import 'package:toolbox/data/model/sftp/absolute_path.dart';
import 'package:toolbox/data/model/sftp/download_worker.dart';

View File

@@ -24,7 +24,7 @@ EXTERNAL SOURCES:
:path: Flutter/ephemeral/.symlinks/plugins/url_launcher_macos/macos
SPEC CHECKSUMS:
FlutterMacOS: 57701585bf7de1b3fc2bb61f6378d73bbdea8424
FlutterMacOS: ae6af50a8ea7d6103d888583d46bd8328a7e9811
path_provider_macos: 3c0c3b4b0d4a76d2bf989a913c2de869c5641a19
share_plus_macos: 853ee48e7dce06b633998ca0735d482dd671ade4
url_launcher_macos: 597e05b8e514239626bcf4a850fcf9ef5c856ec3

View File

@@ -35,7 +35,7 @@ packages:
name: async
url: "https://pub.dartlang.org"
source: hosted
version: "2.8.2"
version: "2.9.0"
boolean_selector:
dependency: transitive
description:
@@ -49,14 +49,7 @@ packages:
name: characters
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0"
charcode:
dependency: transitive
description:
name: charcode
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.1"
version: "1.2.1"
circle_chart:
dependency: "direct main"
description:
@@ -79,7 +72,7 @@ packages:
name: clock
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0"
version: "1.1.1"
collection:
dependency: transitive
description:
@@ -165,7 +158,7 @@ packages:
name: fake_async
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.0"
version: "1.3.1"
ffi:
dependency: transitive
description:
@@ -325,21 +318,21 @@ packages:
name: matcher
url: "https://pub.dartlang.org"
source: hosted
version: "0.12.11"
version: "0.12.12"
material_color_utilities:
dependency: transitive
description:
name: material_color_utilities
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.4"
version: "0.1.5"
meta:
dependency: transitive
description:
name: meta
url: "https://pub.dartlang.org"
source: hosted
version: "1.7.0"
version: "1.8.0"
mime:
dependency: transitive
description:
@@ -360,7 +353,7 @@ packages:
name: path
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.1"
version: "1.8.2"
path_provider:
dependency: "direct main"
description:
@@ -533,7 +526,7 @@ packages:
name: source_span
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.2"
version: "1.9.0"
stack_trace:
dependency: transitive
description:
@@ -554,21 +547,21 @@ packages:
name: string_scanner
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0"
version: "1.1.1"
term_glyph:
dependency: transitive
description:
name: term_glyph
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0"
version: "1.2.1"
test_api:
dependency: transitive
description:
name: test_api
url: "https://pub.dartlang.org"
source: hosted
version: "0.4.9"
version: "0.4.12"
typed_data:
dependency: transitive
description: