flush method

Future<void> flush()

Immediately executes any pending action and cancels timers.

Returns a Future that completes when the action finishes. Throws a StateError if the debouncer has been disposed.

Implementation

Future<void> flush() async {
  _ensureNotDisposed();
  if (_isPaused) {
    _logDebug('Cannot flush while paused.');
    return;
  }
  if (_lastAction != null) {
    await _executeAction(_lastAction!);
    _cancelTimers();
    _logDebug('Flushed action.');
    _publishState();
  }
}