From f082a75d9c8482d76ec7a0d8b6fd2d62875cd8da Mon Sep 17 00:00:00 2001 From: Henry-Hiles Date: Thu, 15 Oct 2026 14:25:45 -0400 Subject: [PATCH] run GomuksStart on an isolate --- lib/controllers/gomuks_listener.dart | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/controllers/gomuks_listener.dart b/lib/controllers/gomuks_listener.dart index ef536c7..62c16c5 100644 --- a/lib/controllers/gomuks_listener.dart +++ b/lib/controllers/gomuks_listener.dart @@ -1,5 +1,6 @@ import "dart:async"; import "dart:ffi"; +import "dart:isolate"; import "package:fast_immutable_collections/fast_immutable_collections.dart"; import "package:flutter/foundation.dart"; @@ -112,12 +113,20 @@ class GomuksListenerController extends AsyncNotifier { ref.onDispose(callable.close); - final errorCode = GomuksStart(handle, callable.nativeFunction); + final errorCode = await _start(handle, callable.nativeFunction); if (errorCode != 0) { throw Exception("GomuksStart returned error code $errorCode"); } } + static Future _start( + int handle, + Pointer< + NativeFunction, Int64, GomuksOwnedBuffer)> + > + callback, + ) => Isolate.run(() => GomuksStart(handle, callback)); + static final provider = AsyncNotifierProvider( GomuksListenerController.new, );