Skip to content

[Bug]: Permission.locationAlways.request doesn't wait for selection in system dialog #1457

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

Open
3 of 5 tasks
KrsticM opened this issue Mar 10, 2025 · 11 comments
Open
3 of 5 tasks

Comments

@KrsticM
Copy link

KrsticM commented Mar 10, 2025

Please check the following before submitting a new issue.

Please select affected platform(s)

  • Android
  • iOS
  • Windows

Steps to reproduce

When calling await Permission.locationAlways.request() system dialog is shown but lib is not waiting for a selection, instead it just returns .denied.

Expected results

To wait for a selection in location permission system dialog.

Actual results

PermissionStatus.denied is returned right away.

Code sample

Code sample
import 'dart:async';
import 'package:permission_handler/permission_handler.dart';
import 'package:vegetation_manager/common/helper/location_permission_manager.dart';

final class LocationPermissionManagerImpl implements LocationPermissionManager {
  @override
  Future<bool> isLocationAlwaysAllowed() async {
    var locationAlwaysStatus = await Permission.locationAlways.status;

    if (!locationAlwaysStatus.isGranted) {
      final whenInUseStatus = await Permission.locationWhenInUse.request();

      if (whenInUseStatus.isGranted) {
        // Not waiting for user to choose option in dialog, instead returning .denied right away
        locationAlwaysStatus = await Permission.locationAlways.request();
        return locationAlwaysStatus.isGranted;
      }
      return false;
    }
    return true;
  }
}

Screenshots or video

Screenshots or video demonstration

[Upload media here]

Version

11.4.0

Flutter Doctor output

Doctor output
flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.27.0, on macOS 15.3.1 24D70 darwin-arm64, locale en-RS)
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.1)
[✓] Xcode - develop for iOS and macOS (Xcode 16.2)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2021.2)
[✓] VS Code (version 1.98.0)
[✓] Connected device (5 available)
[✓] Network resources

• No issues found!
@vilorel
Copy link

vilorel commented Mar 10, 2025

I run into the same error -- same parameters.

@AndRud
Copy link

AndRud commented Mar 12, 2025

I got the same error

@v1n4ester
Copy link

Did someone find any solutions?

@KrsticM
Copy link
Author

KrsticM commented Mar 12, 2025

I have made a timer to check for Permission.locationAlways.status every second until it is granted. It's not pretty but it works with some edge cases.

@v1n4ester
Copy link

I have made a timer to check for Permission.locationAlways.status every second until it is granted. It's not pretty but it works with some edge cases.

What if user deny the permission?

@KrsticM
Copy link
Author

KrsticM commented Mar 12, 2025

I have made a timer to check for Permission.locationAlways.status every second until it is granted. It's not pretty but it works with some edge cases.

What if user deny the permission?

I'm waiting for 30 seconds, if it's not granted in that period I assume it's denied.

@vilorel
Copy link

vilorel commented Mar 14, 2025

@v1n4ester This is not optimal, as you also said. The location and locationWhenInSure both work, so the locationAlways should work by extension. It's therefore a bug that should be addressed via either a PR or by the community maintaining the plugin.

@vilorel
Copy link

vilorel commented Mar 26, 2025

any updates? I would imagine this is high priority for many devs

@v1n4ester
Copy link

any updates? I would imagine this is high priority for many devs

Nope, problem still exist

@spoorknight
Copy link

I got the same error

@loregr
Copy link

loregr commented Apr 14, 2025

Same.

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

6 participants