flutter_foreground_task icon indicating copy to clipboard operation
flutter_foreground_task copied to clipboard

How to use receivePort with WillStartForegroundTask

Open gmkado opened this issue 3 years ago • 0 comments

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.

gmkado avatar Oct 26 '22 07:10 gmkado