This commit is contained in:
Hamza-Ayed
2024-02-25 17:27:28 +03:00
parent b33e797f76
commit e2cdf18b59
9 changed files with 114 additions and 45 deletions

View File

@@ -290,6 +290,7 @@ class MapDriverController extends GetxController {
return d['message'][0]['count'];
}
Position? currentPosition;
void startRideFromDriver() async {
changeRideToBeginToPassenger();
isPassengerInfoWindow = false;
@@ -325,7 +326,37 @@ class MapDriverController extends GetxController {
'driverID': box.read(BoxName.driverID).toString(),
});
var d = jsonDecode(res);
mapController!.animateCamera(CameraUpdate.newLatLngZoom(myLocation, 18));
// mapController!.animateCamera(
// CameraUpdate.newLatLngZoom(
// myLocation,
// 12,
// ),
// );
StreamSubscription<Position>? locationSubscription;
try {
locationSubscription =
Geolocator.getPositionStream().listen((Position position) {
currentPosition = position;
// Update camera position on the map
mapController!.animateCamera(
CameraUpdate.newCameraPosition(
CameraPosition(
target: LatLng(position.latitude, position.longitude),
zoom: 7,
),
),
);
}); // Stop listening to GPS updates when the ride is finished
if (!isRideBegin) {
locationSubscription?.cancel();
}
} catch (error) {
debugPrint('Error listening to GPS: $error');
// Handle GPS errors gracefully, e.g., show a user-friendly message
}
update();
print('...................');
print(d);