This commit is contained in:
Hamza-Ayed
2023-09-27 18:30:21 +03:00
parent 7290e5ecc7
commit 5ca5d91cc9
21 changed files with 414 additions and 189 deletions

View File

@@ -23,18 +23,10 @@ class LocationController extends GetxController {
@override
void onInit() async {
super.onInit();
await CRUD().post(link: AppLink.addTokensDriver, payload: {
'token': box.read(BoxName.tokenDriver),
'captain_id': box.read(BoxName.driverID).toString()
});
location = Location();
getLocation();
startLocationUpdates();
}
void startLocationUpdates() async {
// if (Get.find<HomeCaptainController>().isActive) {
// Start the timer to get location every 20 seconds
_locationTimer = Timer.periodic(const Duration(seconds: 20), (timer) async {
await getLocation();
@@ -44,7 +36,10 @@ class LocationController extends GetxController {
'longitude': myLocation.longitude.toString(),
});
});
// }
}
void stopLocationUpdates() {
_locationTimer?.cancel();
}
Future<void> getLocation() async {