startTimer method

void startTimer()

启动倒计时的计时器。

Implementation

void startTimer() {
  if (widget.enableCancel) {
    if (_timer != null) {
      cancelTimer();
    }
  }
  if (_timer != null) {
    return;
  }
  _isPaused = false;
  _currentTime = widget.countdown;
  _notifyProgress();
  notyChange();

  _timer = Timer.periodic(widget.duration, (timer) {
    if (!mounted) {
      timer.cancel();
      _timer = null;
      return;
    }
    if (_currentTime <= 1) {
      _handleComplete();
      return;
    }
    _currentTime -= 1;
    _notifyProgress();
    notyChange();
  });
}