start method
void
start(
{ - String timeFormatter(
- int seconds
)?,
})
Implementation
void start({String Function(int seconds)? timeFormatter}) {
if (_timer != null) return;
_isPaused = false;
isRunningNotifier.value = true;
_timer = Timer.periodic(const Duration(seconds: 1), (timer) {
if (!_isPaused) {
if (isReverse) {
_currentSeconds--;
} else {
_currentSeconds++;
}
if (_currentSeconds < 0 || _currentSeconds > duration) {
stop();
return;
}
timeNotifier.value =
timeFormatter != null
? timeFormatter(_currentSeconds)
: _defaultFormatter(_currentSeconds);
if ((isReverse && _currentSeconds == 0) ||
(!isReverse && _currentSeconds == duration)) {
stop();
}
}
});
}