dispose method
void
dispose()
Disposes the debouncer, cancelling any pending actions, clearing all state, and closing the state stream.
After calling dispose, the debouncer must not be used.
Implementation
void dispose() {
if (_isDisposed) return;
cancel();
_isDisposed = true;
_lastCallTime = null;
_lastExecutionTime = null;
_executionCount = 0;
_executionHistory.clear();
// Publish final state before closing the stream.
const finalState = DebouncerState(
isRunning: false,
isDisposed: true,
executionCount: 0,
);
if (!_stateController.isClosed) {
_stateController.add(finalState);
_stateController.close();
}
_logDebug('Debouncer disposed.');
}