restart method

void restart()

Same is start, but this will restart the Timer every time this is called.

Implementation

void restart() {
  _timer?.cancel();
  _last = null;
  _timer = Timer.periodic(Duration(seconds: refresh), (t) async {
    final connected = await checkConnectivity();
    if (connected && !(_last ?? false)) {
      _stream.add(true);
      _last = true;
    } else if (_last ?? true) {
      _stream.add(false);
      _last = false;
    }
  });
  started = true;
}