start method

void start(
  1. void callback(
    1. int days,
    2. int hours,
    3. int minutes,
    4. int seconds,
    ), {
  2. 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);
  });
}