Update: 2026-06-10 18:11:50
This commit is contained in:
@@ -2570,27 +2570,19 @@ class MapDriverController extends GetxController
|
||||
}
|
||||
|
||||
void _startLocationListening() {
|
||||
_locationSubscription?.cancel();
|
||||
_locationSubscription = geo.Geolocator.getPositionStream(
|
||||
locationSettings: const geo.LocationSettings(
|
||||
accuracy: geo.LocationAccuracy.bestForNavigation,
|
||||
distanceFilter: 2,
|
||||
),
|
||||
).listen((geo.Position pos) {
|
||||
_handleLocationUpdate(pos);
|
||||
});
|
||||
// Location stream is now centralized in LocationController to prevent device hanging.
|
||||
// LocationController will call handleLocationUpdateFromCentral directly.
|
||||
}
|
||||
|
||||
/// [Fix C-4] تحديث myLocation في المستمع الأساسي
|
||||
void _handleLocationUpdate(geo.Position pos) {
|
||||
final newLoc = LatLng(pos.latitude, pos.longitude);
|
||||
void handleLocationUpdateFromCentral(LatLng newLoc, double posSpeed, double posHeading) {
|
||||
myLocation = newLoc; // ← [Fix C-4] تحديث الموقع الفوري
|
||||
_oldLoc = smoothedLocation ?? newLoc;
|
||||
_targetLoc = newLoc;
|
||||
|
||||
_oldHeading = smoothedHeading;
|
||||
if (pos.speed > 0.5) {
|
||||
_targetHeading = pos.heading;
|
||||
if (posSpeed > 0.5) {
|
||||
_targetHeading = posHeading;
|
||||
} else {
|
||||
_targetHeading = _oldHeading;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user