onResume method
Callback when this executor is resumed. Returns true if successfully resumed, false otherwise.
Implementation
@override
Future<bool> onResume() async {
// enqueue immediately if not already on the list, then keep checking once
// pr minute - otherwise the first check (and task) is delayed a full minute.
void enqueueIfMissing() {
if (!AppTaskController().userTaskQueue
.where((task) => task.state == UserTaskState.enqueued)
.any((task) => task.name == configuration!.taskName)) {
onTrigger();
}
}
enqueueIfMissing();
// Use the inherited [timer], which the base onPause()/onDispose() cancel.
timer = Timer.periodic(Duration(minutes: 1), (_) => enqueueIfMissing());
return true;
}