fix gomuks init on android / ios

This commit is contained in:
Henry Hiles 2026-09-18 15:39:45 -04:00
commit 85bb653980
Signed by: Henry-Hiles
SSH key fingerprint: SHA256:VKQUdS31Q90KvX7EkKMHMBpUspcmItAh86a+v7PGiIs

View file

@ -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)