mirror of
https://github.com/GopeedLab/gopeed.git
synced 2026-11-08 01:20:27 +00:00
feat: support flutter 3.10 (#154)
This commit is contained in:
6 files changed
+1171
-459
No files matched your search
@@ -5,7 +5,7 @@ on:
|
||||
|
||||
env:
|
||||
GO_VERSION: 1.19
|
||||
FLUTTER_VERSION: 3.7.12
|
||||
FLUTTER_VERSION: 3.10.6
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
@@ -28,7 +28,7 @@ on:
|
||||
|
||||
env:
|
||||
GO_VERSION: 1.19
|
||||
FLUTTER_VERSION: 3.7.12
|
||||
FLUTTER_VERSION: 3.10.6
|
||||
|
||||
jobs:
|
||||
# lint:
|
||||
|
||||
@@ -17,7 +17,6 @@ LibgopeedBoot create() => LibgopeedBootNative();
|
||||
|
||||
class LibgopeedBootNative implements LibgopeedBoot {
|
||||
late LibgopeedInterface _libgopeed;
|
||||
late SendPort _childSendPort;
|
||||
|
||||
LibgopeedBootNative() {
|
||||
if (!Util.isDesktop()) {
|
||||
@@ -44,11 +43,7 @@ class LibgopeedBootNative implements LibgopeedBoot {
|
||||
|
||||
@override
|
||||
Future<void> stop() async {
|
||||
if (Util.isDesktop()) {
|
||||
await _ffiStop();
|
||||
} else {
|
||||
await _libgopeed.stop();
|
||||
}
|
||||
await _libgopeed.stop();
|
||||
}
|
||||
|
||||
_ffiInit() {
|
||||
@@ -67,90 +62,9 @@ class LibgopeedBootNative implements LibgopeedBoot {
|
||||
|
||||
// FFI run in isolate
|
||||
Future<int> _ffiStart(StartConfig cfg) async {
|
||||
var startCompleter = Completer<int>();
|
||||
|
||||
var mainReceive = ReceivePort();
|
||||
var isolate = await Isolate.spawn((SendPort sendPort) {
|
||||
return await Isolate.run(() async {
|
||||
_ffiInit();
|
||||
var childReceive = ReceivePort();
|
||||
sendPort.send(childReceive.sendPort);
|
||||
|
||||
childReceive.listen((message) async {
|
||||
late _Result result;
|
||||
try {
|
||||
if (message is _StartParam) {
|
||||
result = _StartResult();
|
||||
(result as _StartResult).port = await _libgopeed.start(message.cfg);
|
||||
}
|
||||
if (message is _StopParam) {
|
||||
result = _StopResult();
|
||||
await _libgopeed.stop();
|
||||
childReceive.close();
|
||||
Isolate.exit(sendPort);
|
||||
}
|
||||
} on Exception catch (e) {
|
||||
result.exception = e;
|
||||
}
|
||||
sendPort.send(result);
|
||||
});
|
||||
}, mainReceive.sendPort);
|
||||
|
||||
var childCompleter = Completer<void>();
|
||||
mainReceive.listen((message) {
|
||||
if (message is SendPort) {
|
||||
_childSendPort = message;
|
||||
childCompleter.complete();
|
||||
}
|
||||
if (message is _StartResult) {
|
||||
if (message.exception != null) {
|
||||
startCompleter.completeError(message.exception!);
|
||||
} else {
|
||||
startCompleter.complete(message.port!);
|
||||
}
|
||||
}
|
||||
if (message is _StopResult) {
|
||||
isolate.kill();
|
||||
if (message.exception != null) {
|
||||
_stopCompleter.completeError(message.exception!);
|
||||
} else {
|
||||
_stopCompleter.complete();
|
||||
}
|
||||
}
|
||||
return await _libgopeed.start(cfg);
|
||||
});
|
||||
await childCompleter.future;
|
||||
_childSendPort.send(_StartParam(cfg: cfg));
|
||||
return startCompleter.future;
|
||||
}
|
||||
|
||||
late Completer<void> _stopCompleter;
|
||||
|
||||
Future<void> _ffiStop() async {
|
||||
_stopCompleter = Completer<void>();
|
||||
_childSendPort.send(_StopParam());
|
||||
return _stopCompleter.future;
|
||||
}
|
||||
}
|
||||
|
||||
class _Result {
|
||||
Exception? exception;
|
||||
|
||||
_Result();
|
||||
}
|
||||
|
||||
class _StartParam {
|
||||
final StartConfig cfg;
|
||||
|
||||
_StartParam({required this.cfg});
|
||||
}
|
||||
|
||||
class _StartResult extends _Result {
|
||||
int? port;
|
||||
|
||||
_StartResult();
|
||||
}
|
||||
|
||||
class _StopParam {}
|
||||
|
||||
class _StopResult extends _Result {
|
||||
_StopResult();
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
+221
-214
File diff suppressed because it is too large.
Load diff
@@ -18,7 +18,7 @@ publish_to: "none" # Remove this line if you wish to publish to pub.dev
|
||||
version: 1.3.5+1
|
||||
|
||||
environment:
|
||||
sdk: ">=2.17.6 <3.0.0"
|
||||
sdk: '>=3.0.0 <4.0.0'
|
||||
|
||||
# Dependencies specify other packages that your package needs in order to work.
|
||||
# To automatically upgrade your package dependencies to the latest versions
|
||||
@@ -46,7 +46,7 @@ dependencies:
|
||||
macos_secure_bookmarks: ^0.2.1
|
||||
rounded_loading_button: ^2.1.0
|
||||
url_launcher: ^6.1.6
|
||||
shared_preferences: ^2.0.15
|
||||
shared_preferences: ^2.2.0
|
||||
logger: ^1.3.0
|
||||
desktop_drop: ^0.3.3
|
||||
package_info_plus: ^4.0.0
|
||||
@@ -67,14 +67,11 @@ dev_dependencies:
|
||||
# package. See that file for information about deactivating specific lint
|
||||
# rules and activating additional ones.
|
||||
flutter_lints: ^2.0.0
|
||||
ffigen: ^6.1.2
|
||||
ffigen: ^8.0.2
|
||||
# build json model: flutter pub run build_runner build --delete-conflicting-outputs
|
||||
build_runner: ^2.2.1
|
||||
json_serializable: ^6.3.2
|
||||
flutter_launcher_icons:
|
||||
git:
|
||||
url: https://github.com/fluttercommunity/flutter_launcher_icons.git
|
||||
ref: v0.11.0
|
||||
flutter_launcher_icons: ^0.13.1
|
||||
|
||||
# For information on the generic Dart part of this file, see the
|
||||
# following page: https://dart.dev/tools/pub/pubspec
|
||||
@@ -128,6 +125,7 @@ flutter_icons:
|
||||
generate: true
|
||||
image_path: "assets/icon/icon_macos_1024.png"
|
||||
|
||||
# flutter pub run ffigen
|
||||
ffigen:
|
||||
name: LibgopeedBind
|
||||
description: Bindings to gopeed library.
|
||||
|
||||
Reference in new issue
Block a user