hasInternetConnection method

Future<bool> hasInternetConnection()

Implementation

Future<bool> hasInternetConnection() async {
  try {
    final result = await InternetAddress.lookup('example.com');

    return result.isNotEmpty && result[0].rawAddress.isNotEmpty;
  } catch (_) {
    return false;
  }
}