You cannot select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
	
	
		
			93 lines
		
	
	
		
			2.2 KiB
		
	
	
	
		
			Dart
		
	
		
		
			
		
	
	
			93 lines
		
	
	
		
			2.2 KiB
		
	
	
	
		
			Dart
		
	
| 
								 
											2 months ago
										 
									 | 
							
								import 'package:flutter/material.dart';
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								import 'package:permission_handler/permission_handler.dart';
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								// import 'package:vibration/vibration.dart';
							 | 
						||
| 
								 | 
							
								import 'package:geolocator/geolocator.dart' as geo;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								class PermissionService {
							 | 
						||
| 
								 | 
							
								  // final LocalStorage storage = new LocalStorage("permission");
							 | 
						||
| 
								 | 
							
								  geo.LocationPermission? locationPermission;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								  // AppGlobal appGlobal = new AppGlobal();
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								  // setVibrationPermission(flag) async {
							 | 
						||
| 
								 | 
							
								  //   storage.setItem('isVibration', flag);
							 | 
						||
| 
								 | 
							
								  // }
							 | 
						||
| 
								 | 
							
								  //
							 | 
						||
| 
								 | 
							
								  // isVibrationEnabled() {
							 | 
						||
| 
								 | 
							
								  //   return (storage.getItem('isVibration') == null) ||
							 | 
						||
| 
								 | 
							
								  //           (storage.getItem('isVibration')) == false
							 | 
						||
| 
								 | 
							
								  //       ? false
							 | 
						||
| 
								 | 
							
								  //       : true;
							 | 
						||
| 
								 | 
							
								  // }
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								  // vibrate(callback, context) async {
							 | 
						||
| 
								 | 
							
								  //   if (callback == null) return null;
							 | 
						||
| 
								 | 
							
								  //   if (isVibrationEnabled() == true) {
							 | 
						||
| 
								 | 
							
								  //     // if (await Vibration.hasVibrator() !=null) {
							 | 
						||
| 
								 | 
							
								  //     //   Vibration.vibrate(duration: 100);
							 | 
						||
| 
								 | 
							
								  //     //   callback();
							 | 
						||
| 
								 | 
							
								  //     // }
							 | 
						||
| 
								 | 
							
								  //   } else {
							 | 
						||
| 
								 | 
							
								  //     callback();
							 | 
						||
| 
								 | 
							
								  //   }
							 | 
						||
| 
								 | 
							
								  // }
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								  // setTheme(flag) async {
							 | 
						||
| 
								 | 
							
								  //   storage.setItem('isTheme', flag);
							 | 
						||
| 
								 | 
							
								  // }
							 | 
						||
| 
								 | 
							
								  //
							 | 
						||
| 
								 | 
							
								  // isThemeEnabled() {
							 | 
						||
| 
								 | 
							
								  //   return storage.getItem('isTheme');
							 | 
						||
| 
								 | 
							
								  // }
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								  cameraPermission() async {
							 | 
						||
| 
								 | 
							
								    Map<Permission, PermissionStatus> statuses = await [
							 | 
						||
| 
								 | 
							
								      Permission.camera,
							 | 
						||
| 
								 | 
							
								    ].request();
							 | 
						||
| 
								 | 
							
								  }
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								  static isCameraEnabled() async {
							 | 
						||
| 
								 | 
							
								    return await Permission.camera.isGranted;
							 | 
						||
| 
								 | 
							
								  }
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								  static isExternalStorageEnabled() async {
							 | 
						||
| 
								 | 
							
								    return await Permission.storage.isGranted;
							 | 
						||
| 
								 | 
							
								  }
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								  static isHealthDataPermissionEnabled() async {
							 | 
						||
| 
								 | 
							
								    return await Permission.sensors.isGranted;
							 | 
						||
| 
								 | 
							
								  }
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								  static isMicrophonePermissionEnabled() async {
							 | 
						||
| 
								 | 
							
								    return await Permission.microphone.isGranted;
							 | 
						||
| 
								 | 
							
								  }
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								  static isCalendarPermissionEnabled() async {
							 | 
						||
| 
								 | 
							
								    return await Permission.calendarFullAccess.isGranted;
							 | 
						||
| 
								 | 
							
								  }
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								  setCameraLocationPermission(context) async {
							 | 
						||
| 
								 | 
							
								    Navigator.pop(context);
							 | 
						||
| 
								 | 
							
								    openAppSettings();
							 | 
						||
| 
								 | 
							
								  }
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								  static isLocationEnabled() async {
							 | 
						||
| 
								 | 
							
								    var permission = await geo.Geolocator.checkPermission();
							 | 
						||
| 
								 | 
							
								    if (permission == geo.LocationPermission.denied) {
							 | 
						||
| 
								 | 
							
								      return false;
							 | 
						||
| 
								 | 
							
								    } else {
							 | 
						||
| 
								 | 
							
								      return true;
							 | 
						||
| 
								 | 
							
								    }
							 | 
						||
| 
								 | 
							
								  }
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								  openSettings() async {
							 | 
						||
| 
								 | 
							
								    openAppSettings();
							 | 
						||
| 
								 | 
							
								  }
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								  openAccessbility() {
							 | 
						||
| 
								 | 
							
								    // OpenSettings.openAppSetting();
							 | 
						||
| 
								 | 
							
								  }
							 | 
						||
| 
								 | 
							
								}
							 |