isNetworkAvailable static method
Implementation
static Future<bool> isNetworkAvailable() async {
try {
final result = await InternetAddress.lookup('google.com');
if (result.isNotEmpty && result[0].rawAddress.isNotEmpty) {
debugPrint('connected');
return true;
} else {
return false;
}
} on SocketException catch (e) {
debugPrint('not connected: $e');
return false;
}
}