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

Strange Behavior on Flutter 0.7.3 #23

Closed
1 of 2 tasks
penjual opened this issue Sep 7, 2018 · 2 comments
Closed
1 of 2 tasks

Strange Behavior on Flutter 0.7.3 #23

penjual opened this issue Sep 7, 2018 · 2 comments
Assignees

Comments

@penjual
Copy link

penjual commented Sep 7, 2018

🐛 Bug Report

[VERBOSE-2:shell.cc(181)] Dart Error: Unhandled exception:
PlatformException(ERROR_ALREADY_REQUESTING_PERMISSIONS, A request for permissions is already running, please wait for it to finish before doing another request (note that you can request multiple permissions at the same time)., null)

Expected behavior

Reproduction steps

List<PermissionGroup> permissionGroup = [
  PermissionGroup.location,
  PermissionGroup.camera,
  // PermissionGroup.storage,
];
if (Theme.of(context).platform == TargetPlatform.android)
  permissionGroup.add(PermissionGroup.storage);

List<String> ungranted = [];
Map<PermissionGroup, PermissionStatus> permissionList =
    await permissionHandler.requestPermissions(permissionGroup);
permissionList.forEach((a, b) {
  if (b != PermissionStatus.granted) {
    if (a != PermissionGroup.locationAlways &&
        a != PermissionGroup.locationWhenInUse)
      ungranted.add(
          a.toString().replaceAll('PermissionGroup.', '- ').toUpperCase());
  }
});

return ungranted;

Configuration

Version: 2.0.0

Platform:

  • 📱 iOS
  • 🤖 Android
@mvanbeusekom mvanbeusekom self-assigned this Sep 7, 2018
@mvanbeusekom
Copy link
Member

Hi @penjual, thank you for contacting us.

Unfortunately I am not able to reproduce this error. I do see however that you are using an instance of the permissionHandler that is defined outside of the code snippet. This makes it a bit hard for me to triage what is exactly happening. However I suspect that the code snippet is ran multiple times (at least two) and the previous calls are not yet finished.

In other words (as the error message also tries to explain), you cannot run multiple requests on the same instance of the PermissionHandler at the same time (you will always have to wait for the first call to finish before executing a second call).

Just for your information, here is what I did to try and reproduce your issue:

  • Cloned the latest version of the PermissionHandler;
  • Pasted your code (minus the return statement) into the void requestPermission(PermissionGroup permission) async { ... } method of the example App (in the file example/lib/main.dart);
  • Run the example App and tap on one of the items in the list.

I am running on the following environment:

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel dev, v0.8.0, on Mac OS X 10.13.6 17G65, locale en-NL)
[✓] Android toolchain - develop for Android devices (Android SDK 28.0.0)
[✓] iOS toolchain - develop for iOS devices (Xcode 9.4.1)
[✓] Android Studio (version 3.1)
[✓] IntelliJ IDEA Ultimate Edition (version 2018.2.1)
[✓] VS Code (version 1.26.1)
[✓] Connected devices (2 available)

And tested on a simulated iPhone 6 (iOS: 9.3)

For now I will close this issue, if you have more questions or information please feel free to reply to this issue and we will re-open it if necessary.

@ened
Copy link
Contributor

ened commented May 16, 2019

Can reproduce the issue using the sample App.

Use two fingers to request multiple permissions at the same time. The result.error call is not followed by a return call. PR inbound.

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

3 participants