startCountDown method
void
startCountDown()
Start the countdown Timer.
Implementation
void startCountDown() {
if (_isActive || mInterval <= 0 || mTotalTime <= 0) return;
_isActive = true;
Duration duration = Duration(milliseconds: mInterval);
_doCallback(mTotalTime);
_mTimer = Timer.periodic(duration, (Timer timer) {
int time = mTotalTime - mInterval;
mTotalTime = time;
if (time >= mInterval) {
_doCallback(time);
} else if (time == 0) {
_doCallback(time);
cancel();
} else {
timer.cancel();
Future.delayed(Duration(milliseconds: time), () {
mTotalTime = 0;
_doCallback(0);
cancel();
});
}
});
}