Flutter file_picker returns 'null' on Android API 34

160 Views Asked by At

i have built a flutter social media app and use the plugin "file_picker" to pick an image from the gallery as the profile image:

FilePickerResult? result =
  await FilePicker.platform.pickFiles(
  type: FileType.media,
  allowMultiple: false,
);

But when i try to pick an image from my android phone (API level 33) or android emulator (API level 34), the file_picker just returns 'null' and 'User cancelled the picker request'.

print(result);

Output:

I/FilePickerDelegate( 1841): User cancelled the picker request
I/flutter ( 1841): null

Any idea what is going on here?

If i create an emulator with API level 31 or below, everything works as expected and i can pick images from all sorts of folders.

Thanks in advance!

1

There are 1 best solutions below

1
K.D.Dilshan On

*You should give permission for access storage from gallery.

remove allowMultiple: false

and update like this,

FilePickerResult? result = await FilePicker.platform.pickFiles(type: FileType.image);