watchGeolocationPosition method
Implementation
Stream<GeolocationPosition> watchGeolocationPosition({
bool enableHighAccuracy = true,
Duration timeout = const Duration(seconds: 15),
Duration maximumAge = const Duration(minutes: 5),
}) {
final controller = StreamController<GeolocationPosition>();
final watchId = watchPosition(
(GeolocationPosition geoPos) {
controller.add(geoPos);
}.toJS,
(GeolocationPositionError geoPosError) {
controller.addError(geoPosError);
}.toJS,
PositionOptions(
enableHighAccuracy: enableHighAccuracy,
timeout: timeout.inMilliseconds,
maximumAge: maximumAge.inMilliseconds),
);
controller.onCancel = () {
clearWatch(watchId);
};
var stream = controller.stream;
return stream;
}