restart method

void restart({
  1. int? duration,
})

This Method Restarts the Countdown Timer, Here optional int parameter duration is the updated duration for countdown timer

Implementation

void restart({int? duration}) {
  if (_isReverse != null && _state != null && _state?._controller != null) {
    _state?._controller!.duration = Duration(
        seconds: duration ?? _state!._controller!.duration!.inSeconds);
    if (_isReverse!) {
      _state?._controller?.reverse(from: 1);
    } else {
      _state?._controller?.forward(from: 0);
    }
    isStarted.value = true;
    isRestarted.value = true;
    isPaused.value = false;
    isResumed.value = false;
  }
}