startTimer method

void startTimer()

Implementation

void startTimer() {
  if (!mounted) {
    return;
  }

  if (_lastRefresh == null) {
    _lastRefresh = DateTime.now();

    setState(() {});

    return;
  }

  if (DateTime.now().difference(_lastRefresh!).inMilliseconds >
      widget.delayInMilliseconds) {
    _lastRefresh = DateTime.now();

    setState(() {});

    return;
  }

  if (_timer == null) {
    _timer = Timer(Duration(milliseconds: widget.delayInMilliseconds), () {
      if (!mounted) {
        return;
      }

      setState(() {});
    });

    return;
  }
}