CheckUserConnection method
initialize connectivity checking Platform messages are asynchronous, so we initialize in an async method.
Implementation
Future CheckUserConnection() async {
try {
final result = await InternetAddress.lookup('google.com');
if (result.isNotEmpty && result[0].rawAddress.isNotEmpty) {
setState(() {
isOnline = true;
isInternetConnected = true;
});
}
} on SocketException catch (_) {
setState(() {
isOnline = false;
isInternetConnected = false;
});
}
}