5/3/1
This commit is contained in:
@@ -11,6 +11,8 @@ import 'package:SEFER/controller/functions/secure_storage.dart';
|
||||
import 'package:SEFER/main.dart';
|
||||
import 'package:SEFER/views/auth/verify_email_page.dart';
|
||||
import 'package:SEFER/views/home/map_page_passenger.dart';
|
||||
import 'package:location/location.dart';
|
||||
// import 'package:permission_handler/permission_handler.dart';
|
||||
|
||||
class LoginController extends GetxController {
|
||||
final formKey = GlobalKey<FormState>();
|
||||
@@ -147,8 +149,45 @@ class LoginController extends GetxController {
|
||||
}
|
||||
}
|
||||
|
||||
final location = Location();
|
||||
|
||||
// late PermissionStatus permissionGranted = PermissionStatus.denied;
|
||||
Future<void> getLocationPermission() async {
|
||||
bool serviceEnabled;
|
||||
PermissionStatus permissionGranted;
|
||||
|
||||
// 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();
|
||||
}
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
void onInit() async {
|
||||
// permissionLocation = await Permission.locationWhenInUse.isGranted;
|
||||
// print('permisson is ${permissionGranted}');
|
||||
|
||||
super.onInit();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user