Baseflow / Baseflow/flutter-geolocator

[Question]: Windows 11 PlatformException when calling checkPermission method

Open
#1,577 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Dart
Stars
1.3k
Forks
803
Avg merge
8h 16m
Merged PRs (30d)
1

Description

### Please check the following before submitting a new issue.

- [X] I have searched the [existing issues](https://github.com/baseflow/flutter-geolocator/issues).
- [X] I have carefully [read the documentation](https://github.com/baseflow/flutter-geolocator/blob/main/geolocator/README.md).

### Please select for which platform(s) you need help

- [ ] Android
- [ ] iOS
- [ ] Linux
- [ ] macOS
- [ ] Web
- [X] Windows

### Your question

hello, I'm running a flutter app on Windows 11 and keep encountering the error when calling Geolocation.checkPermission()
```
PlatformException (PlatformException(UNKNOWN_ERROR, RequestAccess failed. Check the Geolocation Service is running., null, null))
```

I have enabled Location Services on my local Windows 11 machine and allowed desktop apps to access my location. Is there some configuration I need to add to my flutter app or another Windows 11 setting I need to enable?

Here is my code for reference:
```
bool serviceEnabled = await Geolocator.isLocationServiceEnabled();
if (!serviceEnabled) {
return Future.error('Location services are disabled.');
}

LocationPermission 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.');
}

try {
Position position = await Geolocator.getCurrentPosition(
locationSettings: const LocationSettings(
accuracy: LocationAccuracy.bestForNavigation));

List placemarks =
await placemarkFromCoordinates(position.latitude, position.longitude);
// Process placemarks as needed
return placemarks.first.locality ?? 'Unknown location';
} catch (e) {
print('Error: $e');
throw Exception('Failed to get location');
}
```

### Version

13.0.1

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the Windows 11 failure at Geolocator.checkPermission() after checking the reported Location Services and desktop-app permissions. Compare that behavior with the Windows implementation and its documented configuration; done means identifying the required setting or confirming a plugin defect and documenting the verified resolution.

Written by the indexing model from the issue text.

Assessment

Tech stack
dart, flutter
Domain
desktop-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.