12/12/2
This commit is contained in:
@@ -6,6 +6,8 @@ import 'package:location/location.dart';
|
||||
import 'package:ride/constant/box_name.dart';
|
||||
import 'package:ride/constant/links.dart';
|
||||
import 'package:ride/controller/functions/crud.dart';
|
||||
import 'package:ride/controller/home/captin/home_captain_controller.dart';
|
||||
import 'package:ride/controller/home/payment/captain_wallet_controller.dart';
|
||||
import 'package:ride/main.dart';
|
||||
|
||||
// LocationController.dart
|
||||
@@ -13,8 +15,9 @@ class LocationController extends GetxController {
|
||||
LocationData? _currentLocation;
|
||||
late Location location;
|
||||
bool isLoading = false;
|
||||
bool isActive = false;
|
||||
LatLng myLocation = const LatLng(32.3, 36.3);
|
||||
|
||||
String totalPoints = '0';
|
||||
LocationData? get currentLocation => _currentLocation;
|
||||
Timer? _locationTimer;
|
||||
|
||||
@@ -22,11 +25,17 @@ class LocationController extends GetxController {
|
||||
void onInit() async {
|
||||
super.onInit();
|
||||
location = Location();
|
||||
totalPoints = Get.find<CaptainWalletController>().totalPoints;
|
||||
}
|
||||
|
||||
void startLocationUpdates() async {
|
||||
_locationTimer = Timer.periodic(const Duration(seconds: 20), (timer) async {
|
||||
try {
|
||||
totalPoints = Get.find<CaptainWalletController>().totalPoints;
|
||||
|
||||
// if (isActive) {
|
||||
// if (double.parse(totalPoints) > -100) {
|
||||
print('total point is ll$totalPoints');
|
||||
await getLocation();
|
||||
|
||||
await CRUD().post(link: AppLink.addCarsLocationByPassenger, payload: {
|
||||
@@ -35,6 +44,9 @@ class LocationController extends GetxController {
|
||||
'longitude': myLocation.longitude.toString(),
|
||||
'status': box.read(BoxName.statusDriverLocation).toString()
|
||||
});
|
||||
// }
|
||||
|
||||
// }
|
||||
} catch (e) {
|
||||
// Handle the error gracefully
|
||||
print('Error during location updates: $e');
|
||||
|
||||
Reference in New Issue
Block a user