Baseflow / Baseflow/flutter-permission-handler
[Bug]: If Android "Ask every time" option was used then permission status is always returned as denied even when in application settings it's actually permanently denied.
- 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
Issue looks similar to https://github.com/Baseflow/flutter-permission-handler/issues/1206 but problem is opposite.
1. Request permission (e.g. with Permission.location.request()) and in Android permission dialog select "Ask every time".
2. Request permission second time and in Android permission dialog select "Deny". In this case Android will deny permission permanently (it has same behavior as if on step 1 we choose "Deny").
3. Request permission third again. Result of this and all next requests will be incorrect.
### Expected results
The status is PermissionStatus.permanentlyDenied.
### Actual results
The status is PermissionStatus.denied.
### 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
Screenshots or video demonstration
[Upload media here]
### Version
12.0.1
### Flutter Doctor output
Doctor output
```console
[√] Flutter (Channel stable, 3.35.7, on Microsoft Windows [Version 10.0.19045.6456], locale ru-RU)
[√] Windows Version (10 Enterprise 64-bit, 22H2, 2009)
[√] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[√] Chrome - develop for the web
[X] Visual Studio - develop Windows apps
X Visual Studio not installed; this is necessary to develop Windows apps.
Download at https://visualstudio.microsoft.com/downloads/.
Please install the "Desktop development with C++" workload, including all of its default components
[√] Android Studio (version 2024.2)
[√] IntelliJ IDEA Ultimate Edition (version 2022.1)
[√] Connected device (4 available)
[√] Network resources
```
Contributor guide
Assessment
This issue has not been assessed yet.