I'm developing a flutter application that has some native codes, that is, I use the channel to retrieve some native resources, so far my application works fine, but when using libs to have a floating window in any part of the system I need to use the vm-entry-point to instantiate these windows.
Example:
@pragma("vm:prefer-inline")
void overlayMain() {
WidgetsFlutterBinding.ensureInitialized();
runApp(
const MaterialApp(
debugShowCheckedModeBanner: false,
home: MessangerChatHead(),
),
);
}
By doing this I manage to make a floating window in the app, but inside the dart messagerchatheader class, it cannot find my application channel, and in other parts of the app without being a vm-entry-point I can normally call functions that are in the part Native, has anyone had this problem?
From the little I researched, I saw that the vm-entry-point is used to be called from the native side, that is, Kotlin calls flutter, and maybe that's why it doesn't find the flutter channel that I use in the rest of my application.
The function I use to call the native part is this:
static Future<double> getCpuLoadPerCore(int core) async {
try {
double result = await platform.invokeMethod("cpuLoadPerCore", {"coreNumber": core});
return double.parse(result.toStringAsFixed(2));
} on PlatformException catch (e) {
return Future.value(0);
}
}