pingGoogle static method

Future<bool> pingGoogle()

Implementation

static Future<bool> pingGoogle() async{
  bool isOnline=false;
  try {
    final result = await InternetAddress.lookup('google.com');
    if (result.isNotEmpty && result[0].rawAddress.isNotEmpty) {
      isOnline = true;
    } else
      isOnline = false;
  } on SocketException catch (_) {
    isOnline = false;
  }
  return isOnline;
}