register method

void register(
  1. SchedulerTickCallback callback
)

Registers callback to receive a clock reading on every tick. Idempotent: re-registering the same callback is a no-op. Starts the underlying periodic source if this was the first callback.

Implementation

void register(SchedulerTickCallback callback) {
  _checkNotDisposed();
  final wasEmpty = _callbacks.isEmpty;
  if (!_callbacks.add(callback)) return;
  if (wasEmpty) _startTimer();
}