import 'package:permission_handler/permission_handler.dart';class PermissionUtil {static Future<bool> getLocationStatus() async {Map<Permission, PermissionStatus> statuses = await [Permission.location,].request();return statuses[Permission.location].isGranted;}static Future<bool> judgeLocationAuth() async {var status = await Permission.locationWhenInUse.status;if (status == PermissionStatus.granted) {return true;}else {return false;}} static Future<bool> serviceEnabled() async { bool serviceEnabled = await Geolocator.isLocationServiceEnabled(); return serviceEnabled;}Future<Position> _determinePosition() async {bool serviceEnabled;LocationPermission permission;serviceEnabled = await Geolocator.isLocationServiceEnabled();if (!serviceEnabled) {return Future.error('Location services are disabled.');}permission = await Geolocator.checkPermission();if (permission == LocationPermission.denied) {permission = await Geolocator.requestPermission();if (permission == LocationPermission.denied) {return Future.error('Location permissions are denied');}}if (permission == LocationPermission.deniedForever) {return Future.error('Location permissions are permanently denied, we cannot request permissions.');}return await Geolocator.getCurrentPosition(desiredAccuracy: LocationAccuracy.best,forceAndroidLocationManager: true);}getAddressFromLatLng() async{Position position = await _determinePosition();print('纬度:${position.latitude} 经度:${position.longitude} ');List<Placemark> placeMark = await placemarkFromCoordinates(position.latitude, position.longitude);print('地址:${placeMark[0].administrativeArea} ${placeMark[0].locality}${placeMark[0].subLocality} ${placeMark[0].subAdministrativeArea} ${placeMark[0].thoroughfare} ${placeMark[0].subThoroughfare} ${placeMark[0].name} ${placeMark[0].name}');CommonConfig.lat = position.latitude;CommonConfig.lng = position.longitude;CommonConfig.currentCityName = placeMark[0].locality;return {"provinceName": placeMark[0].administrativeArea,"cityName": placeMark[0].locality,"districtName": placeMark[0].subLocality,};}}