useNetworkState function
Tracks the state of network connection using connectivity_plus
(ref link).
ref link
Implementation
NetworkState useNetworkState() {
final state = useRef(const NetworkState(fetched: false));
final connectivityChanged =
useStream(useMemoized(() => Connectivity().onConnectivityChanged));
state.value = NetworkState(
fetched: connectivityChanged.hasData,
connectivity: connectivityChanged.data);
return state.value;
}