I've just started learning Dart and for the project I had in mind it would rely heavily on using FFI to interoperate with a third party "C" library.
One of the key things I need to do is to register a callback with that native library and have that library asynchronously send events back to my Dart code.
For a proof of concept I do actually have at least the setup for that working - I know that the native callback is registered correctly, I know that it tries to callback into my Dart code, but my problem is that these events are coming in via some thread created by the native library and as expected under these circumstances I get the "cannot invoke native callback outside an isolate" error - I understand why that happens - my question is can anything be done about it.
Researching this led me to not too much in all honestly, I found some samples showing the use of NativePort to send messages from the native side so they were consumed by the proper thread on the Dart side but I can't see how I could use that.
The problem is that I have no control over that native library, I can't make changes to or write things like wrapper functions, I don't really want to write any new native code at all I just want to write Dart code.
Is there any viable solution for this or am I stuck?
I must admit I've been learning Dart for about one day total so I don't have a deep understanding of this yet.