Question
Is it possible to make a C++ application and use Flutter as the GUI framework?
I've made a C++ application that runs on embedded linux (OrangePi) and currently it uses a HMI screen (Nextion). But this really ties me to a specific brand of screen and the features that they provide.
Recently I made a different full GUI application solely using Flutter, and I really like it. It is also much nicer than writing a GUI from scratch with any C++ library and has the bonus of cross platform.
I was wondering if it is possible/sensible to move away from my HMI screen for the C++ application and use Flutter? This would then enable me to probably run it on mobile in the future as well which would be a bonus.
The high level idea would be to run Flutter as the main "thread" and then load in my C++ application as a shared library and run it on a second "thread"/isolate. Then when buttons on the GUI are pressed dart would call through to C and when new data needs displayed on screen C would call through to dart (this direction seems more awkward).
From what I can see online dart-ffi is the tool to use for this. It seems to be able to call from dart to C "easily" but not the other way, unless using callbacks. I don't think that will really work for me as the C++ application will independently need to frequently call to dart to update the GUI without user interaction which rules out using a callback in the traditional sense. I have very limited experience with JNI for doing similar things and it has no problem calling from C to Java/Kotlin so hopefully I'm just missing something in dart-ffi.
NativeCallable.listener looks interesting but it closes the callback after its called every time. I don't really want to do that, I would like C++ to call through when ever it wants. From what I'm reading there it seems to create a new isolate ever time you create a callback. If I was to create lots of callbacks on startup and pass them to the C++ application so that it could use them as normal function calls throughout its lifetime, all these isolates would be an issue.
Is there a way I could make Flutter work for my use case? Am I missing some examples or documentation on how to make it work?