Skip to content

[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. #1501

@ami-com

Description

@ami-com

Please check the following before submitting a new issue.

Please select affected platform(s)

  • Android
  • iOS
  • Windows

Steps to reproduce

Issue looks similar to #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
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<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  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
[√] 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions