addTask method
Adds a pre-configured Task to the end of the queue.
Throws an AssertionError if the batch is currently executing.
Implementation
@pragma('vm:prefer-inline')
void addTask(Task<T> task) {
// Inline the guard directly instead of `_ifNotExecuting(() => ...)`. The
// helper is convenient but it allocates a closure per call; the inline
// form is identical in semantics and allocates nothing.
assert(isNotExecuting, 'Cannot modify while tasks are executing.');
if (isNotExecuting) tasks.add(task);
}