flutter_workmanager icon indicating copy to clipboard operation
flutter_workmanager copied to clipboard

Work manager task cancellation listener

Open sujan-lama opened this issue 4 years ago • 4 comments

I have added the Network policy in the work manager. When a worker is running, I am updating the UI to a loading state in the callback dispatcher. But when the internet is gone, the task is automatically canceled, with no callback. Any idea what can I do?

sujan-lama avatar Feb 26 '21 10:02 sujan-lama

In the WorkManager docs, we can see for onStopped:

This method is invoked when this Worker has been told to stop. At this point, the ListenableFuture returned by the instance of startWork() is also cancelled. This could happen due to an explicit cancellation signal by the user, or because the system has decided to preempt the task. In these cases, the results of the work will be ignored by WorkManager. All processing in this method should be lightweight - there are no contractual guarantees about which thread will invoke this call, so this should not be a long-running or blocking operation.

This should be the signal to bring back to the UI. I will look how to make it available on the Dart side.

ened avatar Jun 10 '21 05:06 ened

any updates??

BenCherif avatar Nov 19 '21 18:11 BenCherif

any updates?

Kuroketsu avatar Dec 09 '23 13:12 Kuroketsu