subscribeConnectivityChange static method
StreamSubscription<List<ConnectivityResult> >
subscribeConnectivityChange(
- ConnectivityChangeListener? listener, {
- bool lookUp = false,
- String lookUpUrl = "google.com",
Implementation
static StreamSubscription<List<ConnectivityResult>> subscribeConnectivityChange(ConnectivityChangeListener? listener, {bool lookUp = false, String lookUpUrl = "google.com"}){
final subscription = Connectivity().onConnectivityChanged.listen((List<ConnectivityResult> result) async {
if(listener != null){
final bool hasInternet = await hasConnection(lookUp: lookUp, lookUpUrl: lookUpUrl);
listener(result.first, hasInternet);
}
});
return subscription;
}