hasInternetConnection static method

Future<bool> hasInternetConnection()

Implementation

static Future<bool> hasInternetConnection() async {
  try {
    final result = await InternetAddress.lookup('8.8.8.8'); // Google's DNS
    return result.isNotEmpty && result[0].rawAddress.isNotEmpty;
  } on SocketException {
    return false;
  }
}