isInternetConnectionAvailable static method

Future<bool> isInternetConnectionAvailable()

Implementation

static Future<bool> isInternetConnectionAvailable() async {
  if (ApplicationProfileManager.isWeb()) {
    return true; // TODO(HyperSpeeed): We could in theory handle this maybe?
  } else {
    try {
      final result = await InternetAddress.lookup('google.com');
      return result.isNotEmpty && result[0].rawAddress.isNotEmpty;
    } catch (_) {}
  }
  return false;
}