executeDartCallBack method
Implementation
void executeDartCallBack(BackgroundMessageHandler callback, {dynamic args}) async {
if (defaultTargetPlatform != TargetPlatform.android) {
return;
}
bool isBackgroundIsolateInitialized = await isBackgroundServiceRunning;
if (!isBackgroundIsolateInitialized) {
isBackgroundIsolateInitialized = await startBackgroundService();
}
debugPrint("executeDartCallBack called, isBackgroundIsolateInitialized: $isBackgroundIsolateInitialized");
if (!isBackgroundIsolateInitialized) throw Exception("Failed to initialize background isolate");
debugPrint("executeDartCallBack called, successfully initialized isolate");
final CallbackHandle? callbackHandle = PluginUtilities.getCallbackHandle(callback);
if (callbackHandle == null) {
throw Exception("callback should be a static or a top level function");
}
Untitled.Untitled_Constants.methodChannel
.invokeMethod(UntitledStrings.executeDartCallbackMethodName, {"dartCallbackHandle": callbackHandle.toRawHandle(), "args": args});
}