9/27/1
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user