work static method

void work({
  1. required String jobName,
  2. required VoidCallback action,
})

Executes the given action only if a job with the same jobName hasn't been executed before.

Parameters:

  • jobName: Unique identifier for the job
  • action: Callback to execute if this is the first time this job is run

If a job with the same name has already been executed, this method does nothing.

Implementation

static void work({required String jobName, required VoidCallback action})
{
  if (_done.contains(jobName)) {
    return;
  }

  _done.add(jobName);
  action();
}