Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

file_picker allowedExtensions filter dosent work

i using extention file_picker in flutter width extention filter

try {
      result = await FilePicker.platform.pickFiles(
        type: FileType.custom,
        allowedExtensions: ['jpeg', 'jpg', 'heic', 'pdf'],
      );
    } catch (e) {
      print('fileSelector ****${e}***');
    }

but in Android i can select all files width any extension. In IOS work this filter fine. Is it a bug in file_picker or do I have to do something additional?

like image 613
Jury Dpling Avatar asked May 03 '26 07:05

Jury Dpling


1 Answers

onPressed: () async {
                              String? outputFile =
                                  await FilePicker.platform.saveFile(
                                allowedExtensions: null,
                                type: FileType.any,
                                dialogTitle:
                                    'Please select an output file:',
                                fileName: 'show',
                              );

                              if (outputFile == null) return;

                              if (!outputFile.endsWith('.pdf')) {
                                outputFile = '$outputFile.pdf';
                              }
                             
                            },

Just put a custom check if the outputFile doesn't have it.

like image 57
Vence Avatar answered May 05 '26 22:05

Vence