beginRest method

void beginRest({
  1. int seconds = 90,
})

Implementation

void beginRest({int seconds = 90}) {
  _restTicker?.cancel();
  if (seconds <= 0) {
    _restTicker = null;
    _restRemaining = Duration.zero;
    notifyListeners();
    return;
  }
  _restRemaining = Duration(seconds: seconds);
  _restTicker = Timer.periodic(const Duration(seconds: 1), (t) {
    if (_restRemaining.inSeconds <= 1) {
      t.cancel();
      _restTicker = null;
      _restRemaining = Duration.zero;
      notifyListeners();
    } else {
      _restRemaining -= const Duration(seconds: 1);
      notifyListeners();
    }
  });
  notifyListeners();
}