Flutter permission_handler package not opening app settings when permission is permanently denied


Solution 1

replace !galleryAccessStatus.isGranted with galleryAccessStatus != PermissionStatus.granted and status.isPermanentlyDenied with status != PermissionStatus.granted

openPhotoGallery() async {
    var galleryAccessStatus = await Permission.mediaLibrary.status;

    if(galleryAccessStatus != PermissionStatus.granted) { //here
      var status = await Permission.mediaLibrary.request();

      if(status != PermissionStatus.granted) {  //here
        await openAppSettings();

Solution 2

I believe this is the best solution I stumbled across. This is the onPressed function of my button that opens the app settings.

onPressed: () async {
                      await openAppSettings();
                      BasicMessageChannel<String?> lifecycleChannel = SystemChannels.lifecycle;
                      lifecycleChannel.setMessageHandler((msg) async {
                        if (msg!.endsWith("resumed")) {
                          List permissionslist = [
                            await Permission.locationWhenInUse.isGranted,
                            await Permission.bluetoothConnect.isGranted,
                            await Permission.bluetoothScan.isGranted,
                            await Permission.storage.isGranted
                          if (permissionslist.firstWhereOrNull((element) => element != true) ==
                              null) {
                            setState(() => arePermissionsGiven = true);
                          else {
                            setState(() => arePermissionsGiven = false);
                        return Future(() => null);
Author by


Updated on January 01, 2023


  • Sumchans
    Sumchans 8 minutes

    Have been working on the permission_handler package for sometime. Trying to figure out the app settings page on ios or android when user permanently denies access for the app.

    My app to begin with needs access to the media library and the camera. Experienced flutter devs please explain in detail if possible. I am a newbie to flutter development and newbie the whole mobile application development as well.

    Here is podfile on ios

    post_install do |installer|
      installer.pods_project.targets.each do |target|
        target.build_configurations.each do |config|
                config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= [
                   ## dart: PermissionGroup.calendar
                   ## dart: PermissionGroup.reminders
                   ## dart: PermissionGroup.contacts
                   # 'PERMISSION_CONTACTS=0',
                   ## dart: PermissionGroup.camera
                   # 'PERMISSION_CAMERA=1',
                   ## dart: PermissionGroup.microphone
                   # 'PERMISSION_MICROPHONE=0',
                   ## dart: PermissionGroup.speech
                   ## dart: PermissionGroup.photos
                   # 'PERMISSION_PHOTOS=1',
                   ## dart: [PermissionGroup.location, PermissionGroup.locationAlways, PermissionGroup.locationWhenInUse]
                   ## dart: PermissionGroup.notification
                   # 'PERMISSION_NOTIFICATIONS=0',
                   ## dart: PermissionGroup.mediaLibrary
                   # 'PERMISSION_MEDIA_LIBRARY=1',
                   ## dart: PermissionGroup.sensors

    Here is the info.plist-

        <string>This app requires access to your photo gallery to view or save images</string>

    Here is my actual code, on button press I am checking if permission is there to open gallery

        icon: const Icon(
              size: 50,
       label: const Text('Pick from gallery',
          style: TextStyle(fontSize: 20)),
        onPressed: () {

    Here is my permissions class. The app doesn't open the app settings instead it just loads up the settings on ios.

    import 'package:permission_handler/permission_handler.dart';
    class PermissionService {
      openPhotoGallery() async {
        var galleryAccessStatus = await Permission.mediaLibrary.status;
        if(!galleryAccessStatus.isGranted) {
          var status = await Permission.mediaLibrary.request();
          if(status.isPermanentlyDenied) {
            await openAppSettings();

    Adding this snip after viewing Zeeyans answer. The openAppSettings does not open the app settings page instead it opens the Settings page. enter image description here

  • Sumchans
    Sumchans about 1 year
    The issue is the openAppSettings() does not open the app settings instead it opens the ios setting page. I have added more context to the original post.