From b735283f27c712d66c15f94f04891c678fb891d1 Mon Sep 17 00:00:00 2001 From: stopflock Date: Tue, 26 Aug 2025 22:58:24 -0500 Subject: [PATCH] smoother follow me --- lib/widgets/map_view.dart | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/lib/widgets/map_view.dart b/lib/widgets/map_view.dart index 8616831..83911b1 100644 --- a/lib/widgets/map_view.dart +++ b/lib/widgets/map_view.dart @@ -136,7 +136,11 @@ class MapViewState extends State { void didUpdateWidget(covariant MapView oldWidget) { super.didUpdateWidget(oldWidget); if (widget.followMe && !oldWidget.followMe && _currentLatLng != null) { - _controller.move(_currentLatLng!, _controller.camera.zoom); + // Use smooth animation when follow me is first enabled + _controller.animatedMove( + _currentLatLng!, + _controller.camera.zoom, + ); } } @@ -145,15 +149,26 @@ class MapViewState extends State { if (perm == LocationPermission.denied || perm == LocationPermission.deniedForever) return; + // Configure location settings for smoother tracking + const locationSettings = LocationSettings( + accuracy: LocationAccuracy.high, + distanceFilter: 1, // Update every 1 meter + timeLimit: Duration(seconds: 2), // Max 2 seconds between updates + ); + _positionSub = - Geolocator.getPositionStream().listen((Position position) { + Geolocator.getPositionStream(locationSettings: locationSettings).listen((Position position) { final latLng = LatLng(position.latitude, position.longitude); setState(() => _currentLatLng = latLng); if (widget.followMe) { WidgetsBinding.instance.addPostFrameCallback((_) { if (mounted) { try { - _controller.move(latLng, _controller.camera.zoom); + // Use smooth animation instead of instant jump + _controller.animatedMove( + latLng, + _controller.camera.zoom, + ); } catch (e) { debugPrint('MapController not ready yet: $e'); }