From 85bb653980ba0b69da6b999f9bf31e661c3d913a Mon Sep 17 00:00:00 2001 From: Henry-Hiles Date: Fri, 18 Sep 2026 15:39:45 -0400 Subject: [PATCH] fix gomuks init on android / ios --- lib/controllers/client.dart | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/lib/controllers/client.dart b/lib/controllers/client.dart index 931c023..a535b1e 100644 --- a/lib/controllers/client.dart +++ b/lib/controllers/client.dart @@ -54,17 +54,8 @@ import "package:path_provider/path_provider.dart"; class ClientController extends AsyncNotifier { @override Future build() async { - final handle = await Isolate.run(() async { - final Pointer 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 { throw Exception("GomuksStart returned error code $errorCode"); } + Future init(String path) => Isolate.run( + () => GomuksInit( + ((Platform.isAndroid || Platform.isIOS) ? path.toNativeUtf8() : nullptr) + .cast(), + ), + ); + Future callGomuksMethod( Map data, FutureOr Function(int handle, GomuksBorrowedBuffer data)