useGeolocation function
Tracks the state of user's geographic location using geolocator
(ref link).
ref link
Implementation
GeolocationState useGeolocation({
LocationSettings? locationSettings,
}) {
final state = useRef(const GeolocationState());
final positionChanged = useStream(useMemoized(
() => Geolocator.getPositionStream(locationSettings: locationSettings)));
state.value = GeolocationState(
fetched: positionChanged.hasData,
position: positionChanged.data,
);
return state.value;
}