start method
void
start(
- void callback(
- int days,
- int hours,
- int minutes,
- int seconds,
), {
- int step = 1000,
})
Implementation
void start(void Function(int days, int hours, int minutes, int seconds) callback, {int step = 1000}) {
stop();
_restOfTime = 0;
_timer = Timer.periodic(Duration(milliseconds: step), (timer) {
_restOfTime += step;
int diff = _restOfTime;
int days = diff ~/ _dayUnit;
diff = diff - days * _dayUnit;
int hours = diff ~/ _hourUnit;
diff = diff - hours * _hourUnit;
int minute = diff ~/ _minuteUnit;
diff = diff - minute * _minuteUnit;
int second = diff ~/ _secondUnit;
callback(days, hours, minute, second);
});
}