fix gomuks init on android / ios
This commit is contained in:
parent
a9d2ccbcd1
commit
85bb653980
1 changed files with 9 additions and 11 deletions
|
|
@ -54,17 +54,8 @@ import "package:path_provider/path_provider.dart";
|
||||||
class ClientController extends AsyncNotifier<int> {
|
class ClientController extends AsyncNotifier<int> {
|
||||||
@override
|
@override
|
||||||
Future<int> build() async {
|
Future<int> build() async {
|
||||||
final handle = await Isolate.run(() async {
|
final path = "${(await getApplicationSupportDirectory()).path}/gomuks";
|
||||||
final Pointer<Char> root;
|
final handle = await init(path);
|
||||||
if (Platform.isAndroid || Platform.isIOS) {
|
|
||||||
final dir = await getApplicationSupportDirectory();
|
|
||||||
root = "${dir.path}/gomuks".toNativeUtf8().cast();
|
|
||||||
} else {
|
|
||||||
root = nullptr.cast();
|
|
||||||
}
|
|
||||||
|
|
||||||
return GomuksInit(root);
|
|
||||||
});
|
|
||||||
|
|
||||||
final callable =
|
final callable =
|
||||||
NativeCallable<
|
NativeCallable<
|
||||||
|
|
@ -161,6 +152,13 @@ class ClientController extends AsyncNotifier<int> {
|
||||||
throw Exception("GomuksStart returned error code $errorCode");
|
throw Exception("GomuksStart returned error code $errorCode");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<int> init(String path) => Isolate.run(
|
||||||
|
() => GomuksInit(
|
||||||
|
((Platform.isAndroid || Platform.isIOS) ? path.toNativeUtf8() : nullptr)
|
||||||
|
.cast(),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
Future<dynamic> callGomuksMethod(
|
Future<dynamic> callGomuksMethod(
|
||||||
Map<String, dynamic> data,
|
Map<String, dynamic> data,
|
||||||
FutureOr<GomuksResponse> Function(int handle, GomuksBorrowedBuffer data)
|
FutureOr<GomuksResponse> Function(int handle, GomuksBorrowedBuffer data)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue