1

I am using file_picker 5.0.1, while selecting image from Android device Gallery app it shows this error.

I/FilePickerDelegate(26740): User cancelled the picker request

This is the code snippet, I am using to call file picker

 FilePickerResult? result =
                            await  FilePicker.platform
                                .pickFiles(
                              type: FileType.image,
                                    allowMultiple: false,
                                    allowCompression: false,
                                    });
                            
                            if (result != null) {
                              print(result.files.length);


                            }

My flutter version : 3.0.5 Android compileSdkVersion : 31 Android minSdkVersion : 19 Android targetSdkVersion : 31

Tushar Asodariya
  • 629
  • 2
  • 7
  • 20

2 Answers2

3

This worked for me https://github.com/miguelpruivo/flutter_file_picker/issues/717#issuecomment-847801191

Updated my AndroidManifest.xml

Before

            android:launchMode="singleInstance"

After

            android:launchMode="singleTask"
Tushar Asodariya
  • 629
  • 2
  • 7
  • 20
0

Check permission is granted and at least one album app is installed in the phone. Also you can try

FilePickerResult? result = await FilePicker.platform.pickFiles(
    type: FileType.custom,
    allowedExtensions: ['jpg', 'png'],
  );

or use this package https://pub.dev/packages/image_picker

Paul Ng
  • 11
  • 1