5/11/4
This commit is contained in:
@@ -1,20 +1,32 @@
|
||||
import 'dart:async';
|
||||
import 'package:SEFER/constant/colors.dart';
|
||||
import 'package:SEFER/views/widgets/elevated_btn.dart';
|
||||
import 'package:background_location/background_location.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:permission_handler/permission_handler.dart';
|
||||
|
||||
class LocationBackgroundController extends GetxController {
|
||||
@override
|
||||
void onInit() {
|
||||
Future<void> onInit() async {
|
||||
super.onInit();
|
||||
requestLocationPermission();
|
||||
configureBackgroundLocation();
|
||||
await requestLocationPermission();
|
||||
await configureBackgroundLocation();
|
||||
}
|
||||
|
||||
Future<void> requestLocationPermission() async {
|
||||
var status = await Permission.locationAlways.status;
|
||||
if (!status.isGranted) {
|
||||
await Permission.locationAlways.request();
|
||||
Get.defaultDialog(
|
||||
title: 'Grant Location'.tr,
|
||||
middleText:
|
||||
'We use location to get accurate and nearest passengers for you'
|
||||
.tr,
|
||||
confirm: MyElevatedButton(
|
||||
kolor: AppColor.greenColor,
|
||||
title: 'Grant Location'.tr,
|
||||
onPressed: () async {
|
||||
await Permission.locationAlways.request();
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user