Baseflow / Baseflow/flutter-permission-handler
[Bug]: Permission status can't distinguish denied vs permanently denied when Android "Ask every time" option is used
- 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
- [ ] iOS
- [ ] Windows
### Steps to reproduce
This issue is a follow-up to [my comment](https://github.com/Baseflow/flutter-permission-handler/pull/1130#issuecomment-1781349808) in https://github.com/Baseflow/flutter-permission-handler/pull/1130.
1. Request permission over and over (e.g. with `Permission.camera.request()`) and deny each time until the result is "permanently denied".
2. Open Android system settings and set the permission in question for the app to "Ask every time".
3. Switch back to the app and check the permission status (e.g. with `Permission.camera.status`).
### Expected results
The status is `PermissionStatus.denied`.
### Actual results
The status is `PermissionStatus.permanentlyDenied`.
### Code sample
Code sample
```dart
import 'package:flutter/material.dart';
import 'package:permission_handler/permission_handler.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatefulWidget {
const MyApp({super.key});
@override
State createState() => _MyAppState();
}
class _MyAppState extends State {
PermissionStatus? _currentStatus;
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(),
body: Center(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Text('Permission Status: $_currentStatus'),
TextButton(
onPressed: _checkStatus,
child: const Text('Check Permission Status'),
),
TextButton(
onPressed: _requestStatus,
child: const Text('Request Permission'),
),
],
),
),
),
);
}
void _checkStatus() async {
final status = await Permission.camera.status;
setState(() {
_currentStatus = status;
});
}
void _requestStatus() async {
final status = await Permission.camera.request();
setState(() {
_currentStatus = status;
});
}
}
```
### Screenshots or video
_No response_
### Version
11.0.1
### Flutter Doctor output
Doctor output
```console
[✓] Flutter (Channel stable, 3.13.9, on macOS 13.6 22G120 darwin-arm64, locale
en-US)
• Flutter version 3.13.9 on channel stable at
/Users/jonathanjoelson/repos/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision d211f42860 (5 days ago), 2023-10-25 13:42:25 -0700
• Engine revision 0545f8705d
• Dart version 3.1.5
• DevTools version 2.25.0
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
• Android SDK at /Users/jonathanjoelson/Library/Android/sdk
• Platform android-33, build-tools 33.0.0
• ANDROID_HOME = /Users/jonathanjoelson/Library/Android/sdk
• Java binary at: /Applications/Android
Studio.app/Contents/jre/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build
11.0.13+0-b1751.21-8125866)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 14.0.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 14A400
• CocoaPods version 1.12.0
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2021.3)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build
11.0.13+0-b1751.21-8125866)
[✓] VS Code (version 1.83.0)
• VS Code at /Users/jonathanjoelson/Desktop/Visual Studio Code.app/Contents
• Flutter extension version 3.74.0
[✓] Connected device (4 available)
• Pixel 4a (mobile) • 0B201JEC221560 • android-arm64 •
Android 13 (API 33)
• iPhone 13 (mobile) • 120E063D-E34D-44F8-A6C3-7CB0146B4B76 • ios •
com.apple.CoreSimulator.SimRuntime.iOS-16-0 (simulator)
• macOS (desktop) • macos • darwin-arm64 •
macOS 13.6 22G120 darwin-arm64
• Chrome (web) • chrome • web-javascript •
Google Chrome 111.0.5563.64
[✓] Network resources
• All expected network resources are available.
• No issues found!
```
Contributor guide
Assessment
This issue has not been assessed yet.