createConnectivityStateSubscribeFunction function
Implementation
ConnectivityStateSubscribeFunction createConnectivityStateSubscribeFunction(
Notifier notifier,
) {
return (handler) {
bool cancelled = false;
void update(
ConnectivityStateChangeNotification notification,
) {
if (cancelled) return;
handler(notification.connectivityState);
}
final unsubscribe = notifier.subscribeToConnectivityStateChanges(update);
return () {
cancelled = true;
unsubscribe();
};
};
}