InternetAvailabilityCubit constructor
InternetAvailabilityCubit()
Implementation
InternetAvailabilityCubit() : super(const InternetAvailabilityState.wifi()) {
checkInternetAvailability();
_internetAvailabilitySubscription = Connectivity()
.onConnectivityChanged
.listen((ConnectivityResult result) {
Future.delayed(
const Duration(seconds: 1),
() {
switch (result) {
case ConnectivityResult.wifi:
emit(const InternetAvailabilityState.wifi());
break;
case ConnectivityResult.mobile:
emit(const InternetAvailabilityState.mobile());
break;
default:
emit(const InternetAvailabilityState.none());
break;
}
debugPrint(state.toString());
},
);
});
}