flutter_background_service
flutter_background_service copied to clipboard
Got error "onStart method must be a top-level or static function" when I changed the function call.
When I'm passing the method like this, then it is working fine:
await flutterBackgroundService.configure(
androidConfiguration: AndroidConfiguration(
// this will be executed when app is in foreground or background in separated isolate
onStart: onStart,
// auto start service
autoStart: true,
isForegroundMode: false,
But If I want to call the onStart() method there, it is showing error of: Unhandled Exception: onStart method must be a top-level or static function. I want to pass some other data to the onStart() to run my custom task in the background. How to do it?
await flutterBackgroundService.configure(
androidConfiguration: AndroidConfiguration(
// this will be executed when app is in foreground or background in separated isolate
onStart: (service) {
onStart(service);
},
// auto start service
autoStart: true,
Same issue here. I can't figure out what the go to solution for communication between the background service and my app is supposed to be.
Has anyone been able to pass parameters to the onStart method?