Multi image picker 2 can't access the storage Flutter

116 Views Asked by At

I am using multi image picker2 package for selecting multiple images or videos from the device. But it's not working on Android 14. It's working on the older version of android. I have given all the permissions to access the images from the device. Permission is showing granted but I am getting an error message that permissions are denied from this package.

Here is my Android manifest file for permission:

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES"/>
<uses-permission android:name="android.permission.READ_MEDIA_VIDEO"/>
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" />

Here my code for loading assets

Map<Permission, PermissionStatus> statuses = await [
                      Permission.photos,
                      Permission.videos,
                      Permission.storage
                    ].request();

                    var photos = statuses[Permission.photos];
                    var videos = statuses[Permission.videos];
                    var storage = statuses[Permission.videos];
                    debugPrint(photos.toString());
                    debugPrint(videos.toString());
                    debugPrint(storage.toString());
                    if (photos!.isGranted || videos!.isGranted) {
                      ref
                          .read(profileSettingsProvider.notifier)
                          .loadAssets(context, ref);
                    } else {
                      openAppSettings();
                    }
Future<void> loadAssets(BuildContext context, WidgetRef ref) async {
    List<Asset> resultList = <Asset>[];
    String errorText = 'No Error Detected';

    try {
      resultList = await MultiImagePicker.pickImages(
        maxImages: 8,
        enableCamera: true,
        selectedAssets: ref.read(selectedImagesProvider.notifier).state,
        cupertinoOptions: CupertinoOptions(
          takePhotoIcon: "chat",
          doneButtonTitle: AppLocalizations.of(context).save,
        ),
        materialOptions: const MaterialOptions(
          actionBarColor: "#EA5D43",
          actionBarTitle: "APP NAME",
          statusBarColor: "#EA5D43",
          allViewTitle: "All Photos",
          useDetailsView: false,
          selectCircleStrokeColor: "#000000",
        ),
      );
    } on Exception catch (e) {
      errorText = e.toString();
    }
  }

It says permission denied every time even if the permission is granted.

0

There are 0 best solutions below