execute static method
start the foreground-service and runs the code you wrote in serviceMain
function in lib/main.dart
and passes the initialData
as the argument that is received in the execution callback you set in ServiceClient
Implementation
static Future<Map<String, dynamic>> execute(ServiceData initialData) async {
await channel.invokeMethod(
_SET_SERVICE_DATA, ServiceDataWrapper(initialData).toJson());
await channel.invokeMethod(_START_SERVICE);
var result = await channel.invokeMethod(_RUN_DART_FUNCTION, "");
Map<String, dynamic> json = jsonDecode(result as String);
return json;
}