timerTread static method

void timerTread([
  1. dynamic end = 10
])

定时关闭

Implementation

static void timerTread([end = 10]) {
  if (_timer != null && _timer!.isActive) {
    _timer?.cancel();
    _timer = null;
  }
  int index = 0;
  _timer = new Timer.periodic(new Duration(seconds: 1), (Timer timer) {
    index++;
    _index = _index;
    if (index >= end) {
      index = 0;
      dismiss();
    }
  });
}