This commit is contained in:
Hamza-Ayed
2025-03-08 19:35:09 +03:00
parent d41314cfed
commit 5a4664ed67
30 changed files with 433 additions and 306 deletions

View File

@@ -37,8 +37,12 @@ class LocationController extends GetxController {
void onInit() async {
super.onInit();
location = Location(); // Initialize the location object
await location.changeSettings(
accuracy: LocationAccuracy.high,
interval: 5000, // 5 seconds
distanceFilter: 0);
await getLocation(); // Fetch the location immediately
startLocationUpdates(); // Start periodic location updates
await startLocationUpdates(); // Start periodic location updates
totalPoints = Get.put(CaptainWalletController()).totalPoints.toString();
isActive = Get.put(HomeCaptainController()).isActive;
@@ -70,7 +74,6 @@ class LocationController extends GetxController {
final locationData = location as Map<String, dynamic>;
// Debugging: Print location data
print('Location Data: $locationData');
// Convert string values to double
final minLatitude =
@@ -83,7 +86,6 @@ class LocationController extends GetxController {
double.tryParse(locationData['max_longitude'].toString()) ?? 0.0;
// Debugging: Print converted values
// print(
// 'Converted Values: minLatitude=$minLatitude, maxLatitude=$maxLatitude, minLongitude=$minLongitude, maxLongitude=$maxLongitude');
if (latitude >= minLatitude &&
@@ -92,7 +94,6 @@ class LocationController extends GetxController {
longitude <= maxLongitude) {
box.write(BoxName.serverChosen,
EncryptionHelper.instance.decryptData(locationData['server_link']));
// Log.print(
// 'locationData----server_link: ${locationData['server_link']}');
return locationData['name'];
}
@@ -122,12 +123,10 @@ class LocationController extends GetxController {
if (myLocation == null) {
return;
}
// print(
// 'Latitude: ${myLocation.latitude}, Longitude: ${myLocation.longitude}');
String area =
getLocationArea(myLocation.latitude, myLocation.longitude);
print('Determined Area: $area');
if (box.read(BoxName.driverID) != null) {
await CRUD().post(
@@ -160,9 +159,7 @@ class LocationController extends GetxController {
}
}
}
} catch (e) {
Log.print('Error during location update: $e');
}
} catch (e) {}
});
}
}