onCancelled

fun Flow<TaskState>.onCancelled(action: suspend () -> Unit): Flow<TaskState>

Invokes action when the task reaches TaskState.Cancelled.