Flutter: How to pick files with filter extensions in any directory?

1.2k Views Asked by At

How to pick file with any extensions using of file_picker package​. And filter with customize paramater extensions even if I open any directory.

Currently, it's working in case the first open. but when I change to other directory it still show files that I don't want.

Please you help to advice me how can I acheive this case. Thank you.

Example: When browse files by filter .pdf enter image description here When I choose Gallery.
enter image description here.
Show .jpg extension. Filter .pdf is not working enter image description here

Future<void> loadFiles(List<String> extensions) async {
    try {
      var platformFiles = await FilePicker.platform.pickFiles(type: FileType.custom, allowMultiple: true, allowedExtensions: extensions);
      if (platformFiles != null) {
        files.value = platformFiles.files;
        Get.to(() => const ConverterScreen());
      }
    } catch {
      print("[ERROR]${e.toString}");
    }
  }

0

There are 0 best solutions below