xxxxxxxxxx
bool result = await InternetConnectionChecker().hasConnection;
xxxxxxxxxx
import 'dart:io';
try {
final result = await InternetAddress.lookup('example.com');
if (result.isNotEmpty && result[0].rawAddress.isNotEmpty) {
print('connected');
}
} on SocketException catch (_) {
print('not connected');
}