jumpTo method

void jumpTo(
  1. Duration duration
)

Function to move the current time.

Implementation

void jumpTo(Duration duration) {
  final isCountUp = begin < end;

  final a = isCountUp ? begin.inMilliseconds : end.inMilliseconds;
  final b = isCountUp ? end.inMilliseconds : begin.inMilliseconds;

  final value = (duration.inMilliseconds - a) / (b - a);
  final next = isCountUp ? value : 1.0 - value;

  if (next <= 0.0 && state.value != CustomTimerState.counting) return reset();
  if (next >= 1.0) return finish();

  _animationController.value = next;
  if (state.value == CustomTimerState.counting)
    start();
  else
    _pause();
}