flutter_foreground_task
flutter_foreground_task copied to clipboard
How to use receivePort with WillStartForegroundTask
Is there a recommended way to retrieve the ReceivePort when using WillStartForegroundTask?
It looks like the FlutterForegroundTask.receivePort property is only valid when the service is running. When using WillStartForegroundTask the service start/stop is handled according to lifecycle events so we don't really know when to retrieve it. I could also subscribe to lifecycle events and retrieve it then, but that seems messy and order dependent.
It would be nice if instead we could pass a listen callback to WillStartForegroundTask widget that gets listened to when the service is started.