checkConnectivity method
Implementation
Future<bool> checkConnectivity() async {
Socket? socket;
bool connectivity;
await Future.delayed(Duration(milliseconds: 100));
try {
socket =
await Socket.connect('google.com', 80, timeout: Duration(seconds: 4));
connectivity = true;
} catch (e) {
checkInternetConnection();
connectivity = false;
} finally {
try {
await socket?.close();
} catch (e) {
print(e);
}
}
print('conn $connectivity');
return connectivity;
}