Baseflow / Baseflow/flutter-permission-handler

[Bug]: PlatformException.code values are not the same between platforms

Open
#1,375 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Dart
Stars
2.2k
Forks
970
Avg merge
14h 22m
Merged PRs (30d)
2

Description

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

- [X] I have searched the [existing issues](https://github.com/baseflow/flutter-permission-handler/issues).
- [X] I have carefully [read the documentation](https://github.com/Baseflow/flutter-permission-handler/blob/main/permission_handler/README.md) and verified I have added the required platform specific configuration.

### Please select affected platform(s)

- [X] Android
- [X] iOS
- [ ] Windows

### Steps to reproduce

1. Request permission on iOS while another request is in progress, e.g. `Permission.locationWhenInUse.request()`
2. Observe PlatformException.code is `ERROR_ALREADY_REQUESTING_PERMISSIONS`
3. Request permission on Android while another request is in progress, e.g. `Permission.locationWhenInUse.request()`
4. Observe PlatformException.code is `PermissionHandler.PermissionManager` **(Ouch!)**

### Expected results

The `PlatformException.code` values for the same errors should be the same between platforms.

### Actual results

On Android the PlatformException contains some generic error code. Here is an example stack trace:

```
PlatformException: PlatformException(PermissionHandler.PermissionManager, 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, null)
#0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:648)
#1 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:334)
File ""
#3 MethodChannelPermissionHandler.requestPermissions (package:permission_handler_platform_interface/src/method_channel/method_channel_permission_handler.dart:80)
File ""
#5 PermissionActions.request (package:permission_handler/permission_handler.dart:109)
File ""
```

### Code sample

N/A

### Screenshots or video

N/A

### Version

11.3.1

### Flutter Doctor output

Doctor output

```console
[✓] Flutter (Channel stable, 3.24.2, on macOS 13.6.6 22G630 darwin-arm64, locale en-CA)
• Flutter version 3.24.2 on channel stable at ...
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 4cf269e36d (6 days ago), 2024-09-03 14:30:00 -0700
• Engine revision a6bd3f1de1
• Dart version 3.5.2
• DevTools version 2.37.2

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
• Android SDK at .../Library/Android/sdk
• Platform android-34, build-tools 34.0.0
• Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 17.0.10+0-17.0.10b1087.21-11572160)
• All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 15.2)
• Xcode at /Applications/Xcode_15.2.app/Contents/Developer
• Build 15C500b
• CocoaPods version 1.15.2

[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] IntelliJ IDEA Ultimate Edition (version 2024.2.1)
• IntelliJ at /Applications/IntelliJ IDEA.app
• Flutter plugin version 81.1.3
• Dart plugin version 242.21829.3

[✓] Connected device (3 available)
• macOS (desktop) • macos • darwin-arm64 • macOS 13.6.6 22G630 darwin-arm64
• Mac Designed for iPad (desktop) • mac-designed-for-ipad • darwin • macOS 13.6.6 22G630 darwin-arm64
• Chrome (web) • chrome • web-javascript • Google Chrome 128.0.6613.120

[✓] Network resources
• All expected network resources are available.

```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.