isInternetAvailable top-level property
Check if internet connection is available.
Implementation
Future<bool> get isInternetAvailable async {
bool status = true;
await InternetAddress.lookup('google.com').onError((error, stackTrace) {
if (error is SocketException) status = false;
return []; //This is for the onError method. Because the body might complete normally, causing 'null' to be returned,
// but the return type, 'FutureOr<List<InternetAddress>>', is a potentially non-nullable type.
});
return status;
}