shouldRun method

  1. @override
FutureOr<bool> shouldRun(
  1. TaskInvocation invocation
)
override

Check if the provided task invocation should run.

Returns true if it should, false otherwise.

Implementation

@override
FutureOr<bool> shouldRun(TaskInvocation invocation) async {
  if (await cache.hasInvocationChanged(invocation)) return true;
  final lastTime = await cache.getLatestInvocationTime(invocation.name);
  if (lastTime == null) {
    return true;
  }
  return clock.now().isAfter(lastTime.add(period));
}