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> {
|
||||
@override
|
||||
Future<int> build() async {
|
||||
final handle = await Isolate.run(() async {
|
||||
final Pointer<Char> root;
|
||||
if (Platform.isAndroid || Platform.isIOS) {
|
||||
final dir = await getApplicationSupportDirectory();
|
||||
root = "${dir.path}/gomuks".toNativeUtf8().cast();
|
||||
} else {
|
||||
root = nullptr.cast();
|
||||
}
|
||||
|
||||
return GomuksInit(root);
|
||||
});
|
||||
final path = "${(await getApplicationSupportDirectory()).path}/gomuks";
|
||||
final handle = await init(path);
|
||||
|
||||
final callable =
|
||||
NativeCallable<
|
||||
|
|
@ -161,6 +152,13 @@ class ClientController extends AsyncNotifier<int> {
|
|||
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(
|
||||
Map<String, dynamic> data,
|
||||
FutureOr<GomuksResponse> Function(int handle, GomuksBorrowedBuffer data)
|
||||
|
|
|
|||
Loading…
Reference in a new issue