Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question]: Windows 11 PlatformException when calling checkPermission method #1577

Open
3 of 8 tasks
Dripcoding opened this issue Sep 28, 2024 · 0 comments
Open
3 of 8 tasks

Comments

@Dripcoding
Copy link

Dripcoding commented Sep 28, 2024

Please check the following before submitting a new issue.

Please select for which platform(s) you need help

  • Android
  • iOS
  • Linux
  • macOS
  • Web
  • 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<Placemark> 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

@Dripcoding Dripcoding changed the title [Question]: [Question]: Windows 11 PlatformException when calling checkPermission method Sep 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant