updateSeconds method

void updateSeconds(
  1. int elapsedSeconds
)

Updates the remaining seconds by subtracting the elapsed time.

Useful when the app resumes from the background. The elapsedSeconds is subtracted from the remaining time, and the value is clamped to zero.

Implementation

void updateSeconds(int elapsedSeconds) {
  _secondsRemaining =
      (_secondsRemaining - elapsedSeconds).clamp(0, duration.inSeconds);
  notifyListeners();
  if (_secondsRemaining == 0) {
    _timer?.cancel();
    if (onTimerEnd != null) {
      onTimerEnd!();
    }
  }
}