Is there any way I can check whether internet connection on user mobile is active, rather than whether it's Wi-Fi or mobile data is turned on.
I tried using the package Connectivity_plus
It's giving me whether Wi-Fi or mobile data is turned on. It doesn't really check it's active internet connection. Could you please help me to sort out.
Below is my code
class ConnectivityProvider with ChangeNotifier {
late bool _isOnline = false;
bool get isOnline => _isOnline;
ConnectivityProvider() {
Connectivity _connectivity = Connectivity();
_connectivity.onConnectivityChanged.listen((result) async {
if (result == ConnectivityResult.none) {
_isOnline = false;
notifyListeners();
} else {
_isOnline = true;
notifyListeners();
}
});
}
}
Many thanks.
Check this package : internet_connection_checker
https://pub.dev/packages/internet_connection_checker
"The reason this package exists is that connectivity_plus package cannot reliably determine if a data connection is actually available."