CustomTimerController constructor
CustomTimerController({
- required TickerProvider vsync,
- required Duration begin,
- required Duration end,
- CustomTimerState initialState = CustomTimerState.reset,
- CustomTimerInterval interval = CustomTimerInterval.milliseconds,
Controls the state of the timer.
Allows you to execute the start()
, pause()
, reset()
and finish()
functions. It also allows you to get or subscribe to the current state
and remaining
time.
Remember to dispose when you are no longer using it.
Implementation
CustomTimerController({
required this.vsync,
required Duration begin,
required Duration end,
this.initialState = CustomTimerState.reset,
this.interval = CustomTimerInterval.milliseconds,
}) {
_begin = begin;
_end = end;
_animationController = AnimationController(vsync: vsync);
_init();
if (initialState == CustomTimerState.finished)
finish();
else if (initialState == CustomTimerState.counting) start();
_animation.addListener(_listener);
_animation.addStatusListener(_statusListener);
}