isInternetAvailable static method

Future<bool> isInternetAvailable()

Implementation

static Future<bool> isInternetAvailable() async {

  print("VERIFICANDO CONEXÃO COM A INTERNET...");

  try {

    final list = await InternetAddress.lookup('google.com');
    if (list.isNotEmpty && list[0].rawAddress.isNotEmpty) {

      print('CONNECTED!');
      return true;

    }
  } on SocketException catch (_) {

    print('NOT CONNECTED!');
    return false;

  }

  return false;

}