hasConnection property

Future<bool> get hasConnection

Initiates a request to each address in addresses. If at least one of the addresses is reachable we assume an internet connection is available and return true. false otherwise.

Implementation

Future<bool> get hasConnection async {
  List<Future<AddressCheckResult>> requests = [];

  for (var addressOptions in addresses) {
    requests.add(isHostReachable(addressOptions));
  }
  _lastTryResults = List.unmodifiable(await Future.wait(requests));

  return _lastTryResults.map((result) => result.isSuccess).contains(true);
}