I’m working on a Flutter application for Linux and need to call a Dart function from my native C++ code. I’ve successfully implemented method channels for calling native C++ functions from Dart, but I’m having trouble with the reverse — calling Dart functions from C++.
Context:
I want to send data from the native C++ side to Dart and invoke a Dart function based on certain events or conditions in the native code.
I’ve explored using Flutter’s platform channels, but all the examples and documentation I found seem to focus on invoking methods from Dart to native code rather than the other way around. Specifically, I tried setting up a MethodChannel
but couldn’t figure out how to call Dart functions directly from the native side.
Goal:
-
Native Side: I need to trigger a Dart function from the native side of my application (C++ for Linux).
-
Dart Side: The Dart function should be callable from the native code and handle any incoming data or events.