start method

void start()

Starts following the platform. Called once by Koolbase.initialize.

Implementation

void start() {
  if (_sub != null) return;
  try {
    final source = _source ?? Connectivity().onConnectivityChanged;
    _sub = source.listen((results) {
      _heard = true;
      _set(_from(results));
    }, onError: (Object _) {});
    final check = _check ?? () => Connectivity().checkConnectivity();
    check().then((results) {
      if (!_heard) _set(_from(results));
    }, onError: (Object _) {});
  } catch (_) {
    // No connectivity plugin on this platform: stays unknown.
  }
}