Update: 2026-06-10 18:11:50

This commit is contained in:
Hamza-Ayed
2026-06-10 18:11:50 +03:00
parent a0473a8b0f
commit 977adfe99d
27 changed files with 3946 additions and 206 deletions

View File

@@ -476,32 +476,18 @@ class NavigationController extends GetxController
}
void _startLocationStream() {
_locationStreamSubscription?.cancel();
// Listen to location updates with minimum distance filter of 2 meters
// This provides real-time updates without the 3-4 second delay
_locationStreamSubscription = Geolocator.getPositionStream(
locationSettings: const LocationSettings(
accuracy: LocationAccuracy.high,
distanceFilter: 2, // Update every 2 meters
),
).listen(
(Position position) {
_handleLocationUpdate(position);
},
onError: (error) {
Log.print("DEBUG: Location stream error: $error");
},
);
// Location stream is now centralized in LocationController to prevent device hanging.
// LocationController will call handleLocationUpdateFromCentral directly.
}
bool _isProcessing = false;
Future<void> _handleLocationUpdate(Position position) async {
Future<void> handleLocationUpdateFromCentral(LatLng newLoc, double locSpeed, double locHeading) async {
if (_isProcessing) return;
_isProcessing = true;
try {
final newLoc = LatLng(position.latitude, position.longitude);
currentSpeed = position.speed * 3.6; // Convert m/s to km/h
currentSpeed = locSpeed; // Convert m/s to km/h already done by location controller if needed, wait location_controller sends raw speed or km/h? It sends raw speed. So we should * 3.6
currentSpeed = locSpeed * 3.6;
// Skip if movement is too small
if (_lastProcessedLocation != null) {
@@ -544,7 +530,7 @@ class NavigationController extends GetxController
_targetLoc!.longitude,
);
} else {
_targetHeading = position.heading;
_targetHeading = locHeading;
}
_animController?.forward(from: 0.0);