feat: Update location pointer colors to use theme color for better consistency

This commit is contained in:
Janez T
2025-10-28 21:21:03 +01:00
parent 002b5f4da0
commit b899c792a6
2 changed files with 25 additions and 5 deletions

View File

@@ -75,6 +75,7 @@ class _MapTabState extends State<MapTab> with AutomaticKeepAliveClientMixin {
bool _backgroundTrackingEnabled = false; // Toggle for background tracking bool _backgroundTrackingEnabled = false; // Toggle for background tracking
StreamSubscription<CompassEvent>? _compassStreamSubscription; StreamSubscription<CompassEvent>? _compassStreamSubscription;
final BackgroundLocationService _backgroundLocationService = BackgroundLocationService(); final BackgroundLocationService _backgroundLocationService = BackgroundLocationService();
bool _isDisposing = false; // Flag to prevent updates during disposal
// MBTiles layers // MBTiles layers
List<MapLayer> _mbtilesLayers = []; List<MapLayer> _mbtilesLayers = [];
@@ -195,8 +196,8 @@ class _MapTabState extends State<MapTab> with AutomaticKeepAliveClientMixin {
// Start listening to compass events // Start listening to compass events
_compassStreamSubscription = compassStream.listen( _compassStreamSubscription = compassStream.listen(
(CompassEvent event) { (CompassEvent event) {
// Double-check mounted status to prevent setState on disposed widget // Check if widget is disposing, mounted, and event has valid heading
if (!mounted || event.heading == null) return; if (_isDisposing || !mounted || event.heading == null) return;
try { try {
setState(() { setState(() {
@@ -205,7 +206,7 @@ class _MapTabState extends State<MapTab> with AutomaticKeepAliveClientMixin {
// Rotate map if rotation mode is enabled and we have compass heading // Rotate map if rotation mode is enabled and we have compass heading
// Only rotate if map is ready // Only rotate if map is ready
if (_rotateMarkerWithHeading && event.heading != null && _isMapReady) { if (_rotateMarkerWithHeading && event.heading != null && _isMapReady && !_isDisposing) {
try { try {
// Use moveAndRotate to set absolute rotation // Use moveAndRotate to set absolute rotation
final camera = _mapController.camera; final camera = _mapController.camera;
@@ -220,8 +221,10 @@ class _MapTabState extends State<MapTab> with AutomaticKeepAliveClientMixin {
} }
} catch (e) { } catch (e) {
// Widget disposed during setState, ignore // Widget disposed during setState, ignore
if (!_isDisposing) {
debugPrint('Compass tracking error: $e'); debugPrint('Compass tracking error: $e');
} }
}
}, },
); );
} }
@@ -415,12 +418,19 @@ class _MapTabState extends State<MapTab> with AutomaticKeepAliveClientMixin {
@override @override
void dispose() { void dispose() {
// Set flag immediately to prevent any async callbacks from firing
_isDisposing = true;
// Cancel compass subscription first to stop new events
_compassStreamSubscription?.cancel();
_compassStreamSubscription = null;
// Save map position before disposing // Save map position before disposing
_saveMapPosition(); _saveMapPosition();
final mapProvider = context.read<MapProvider>(); final mapProvider = context.read<MapProvider>();
mapProvider.removeListener(_handleMapNavigation); mapProvider.removeListener(_handleMapNavigation);
_compassStreamSubscription?.cancel();
// DO NOT stop location tracking - it's managed by AppProvider // DO NOT stop location tracking - it's managed by AppProvider
// Just clear the map-specific callback // Just clear the map-specific callback
_locationService.onPositionUpdate = null; _locationService.onPositionUpdate = null;

10
lib/screens/mcp.json Normal file
View File

@@ -0,0 +1,10 @@
{
"mcpServers": {
"dart": {
"command": "dart",
"args": [
"mcp-server"
]
}
}
}