subscribeToConnectivityChange method
dynamic
subscribeToConnectivityChange({
- required dynamic subscriptionCallback(
- Stream<
ConnectivityWatcherStatus> stream
- Stream<
subscriptionCallback
The method is use to subscribe to the internet changes
method can be used to call apis on network changes
Implementation
subscribeToConnectivityChange(
{required Function(Stream<ConnectivityWatcherStatus> stream)
subscriptionCallback}) {
WidgetsBinding.instance.addPostFrameCallback((_) async {
Stream<ConnectivityWatcherStatus> stream = currentContext
.dependOnInheritedWidgetOfExactType<ConnectivityInheritedWidget>()!
.controller!
.connectivityController
.stream;
subscriptionCallback(stream);
});
}