enqueueTask method

void enqueueTask(
  1. void task()
)

Adds the given task to the queue.

Implementation

void enqueueTask(final void Function() task) {
  final currentTaskIdentity = Object();

  _latestTaskIdentity = currentTaskIdentity;

  scheduleMicrotask(() {
    if (_latestTaskIdentity == currentTaskIdentity) task();
  });
}