try {
final result = await InternetAddress.lookup('google.com');
if (result.isNotEmpty && result[0].rawAddress.isNotEmpty) {
print(' connected');
}
} on SocketException catch (_) {
//NOT connected to the internet
print('not connected');
}