nextTick function

Future<void> nextTick([
  1. VoidCallback? callback
])

Schedules a callback to be executed in the next frame.

This function batches callbacks to be executed in the next animation frame. If a callback is provided, it will be added to the list of callbacks to be executed.

Returns a Future that completes when the next frame is rendered.

Implementation

Future<void> nextTick([VoidCallback? callback]) {
  _startBatch();
  try {
    if (callback != null) {
      _callbacks.add(callback);
    }

    return _evalCompleter!.future;
  } finally {
    _endBatch();
  }
}