add method

void add(
  1. @noFutures TTaskHandler<T> handler, {
  2. @noFutures TOnTaskError? onError,
  3. bool? eagerError,
  4. Duration? minTaskDuration,
})

A convenience method to construct a Task and add it to the queue.

  • handler: The function to execute for this task.
  • onError: An optional error handler specific to this task.
  • eagerError: Overrides the default error handling for this task.
  • minTaskDuration: Overrides the default minimum duration for this task.

Throws an AssertionError if the batch is currently executing.

Implementation

void add(
  @noFutures TTaskHandler<T> handler, {
  @noFutures TOnTaskError? onError,
  bool? eagerError,
  Duration? minTaskDuration,
}) {
  // Subclasses can override this to inject their specific defaults.
  final task = Task(
    handler: handler,
    onError: onError,
    eagerError: eagerError,
    minTaskDuration: minTaskDuration,
  );
  addTask(task);
}