checkConnection static method

Future<bool> checkConnection({
  1. String url = "google.com",
})

Implementation

static Future<bool> checkConnection({String url="google.com"}) async {
  bool connected=false;
  try {
    final result = await InternetAddress.lookup(url);
    if (result.isNotEmpty && result[0].rawAddress.isNotEmpty) {
      connected=true;
    }
  } on SocketException catch (_) {
  }
  return connected;
}