al246
al246

Reputation: 230

Flutter PositionStream isn't updating map location

I have a Flutter app with a map that shows user location

On the simulator, when I change the coords the marker moves.

However, on a physical device it doesn't move at all.

I have a Geolocator Stream to update the marker position

Here is my code

  Position? currentPosition;
  StreamSubscription<Position>? positionStream;

  void listenToLocationChanges() {

    LocationIndicator locationIndicator = LocationIndicator();
    locationIndicator.locationIndicatorStyle = LocationIndicatorIndicatorStyle.pedestrian;

    final LocationSettings locationSettings = LocationSettings(
      accuracy: LocationAccuracy.high,
      distanceFilter: 100,
    );

    positionStream = Geolocator.getPositionStream(locationSettings: locationSettings).listen(
      (Position? position) {
        print(position==null? 'Unknown' : '$position'); 
        

    currentPosition = position;

    GeoCoordinates geoCoordinates = GeoCoordinates (position!.latitude, position.longitude);
    bearing = position.heading;
    currentlat = position.latitude;
    currentlong = position.longitude;

    Location location = Location.withCoordinates(geoCoordinates);
    location.time = DateTime.now();
    location.bearingInDegrees = bearing;
   
    locationIndicator.updateLocation(location);

    _hereMapController.addLifecycleListener(locationIndicator);
    _locationIndicatorList.add(locationIndicator);

      },
    );
  }

Is there any reason why it would work in my simulator when I change the custom coords, it updates fine, but on a device it stays still at the location when opened?

Thanks in advance

Upvotes: 0

Views: 410

Answers (1)

al246
al246

Reputation: 230

I changed distance params and is now accurate

Upvotes: 0

Related Questions