This commit is contained in:
Hamza-Ayed
2024-05-11 17:21:24 +03:00
parent 34c7eea513
commit 940fe26b87
83 changed files with 25 additions and 52 deletions

View File

@@ -1,6 +1,7 @@
import 'dart:convert';
import 'dart:math';
import 'package:SEFER/controller/functions/location_background_controller.dart';
import 'package:flutter/material.dart';
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
import 'package:get/get.dart';
@@ -39,34 +40,8 @@ class LoginCaptinController extends GetxController {
}
Future<void> getLocationPermission() async {
bool serviceEnabled;
PermissionStatus permissionGranted;
Get.put(LocationBackgroundController()).requestLocationPermission();
// Check if location services are enabled
serviceEnabled = await location.serviceEnabled();
if (!serviceEnabled) {
serviceEnabled = await location.requestService();
if (!serviceEnabled) {
// Location services are still not enabled, handle the error
return;
}
}
// Check if the app has permission to access location
permissionGranted = await location.hasPermission();
if (permissionGranted == PermissionStatus.denied) {
permissionGranted = await location.requestPermission();
if (permissionGranted != PermissionStatus.granted) {
// Location permission is still not granted, handle the error
permissionGranted = await location.requestPermission();
return;
}
}
print('permisson is ${permissionGranted.toString()}');
if ('PermissionStatus.granted' == permissionGranted.toString()) {
box.write(BoxName.locationPermission, 'true');
update();
}
update();
}