dispose method

void dispose()

Cancel the timer when the instance is disposed of. This is important to prevent any scheduled execution after the instance is considered no longer needed.

Implementation

void dispose() {
  // Cancel any existing timer to clear the scheduled action
  _timer?.cancel();
}