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, );