Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allowedExtensions not working #1679

Open
3 tasks
Kelvinlby opened this issue Jan 13, 2025 · 2 comments
Open
3 tasks

allowedExtensions not working #1679

Kelvinlby opened this issue Jan 13, 2025 · 2 comments
Labels
new issue An issue that hasn't yet been seen from the maintainer

Comments

@Kelvinlby
Copy link

Describe the bug
allowedExtensions not working when it the list has more than 1 item, file with other extensions can still be selected.

Platform

  • Android
  • iOS
  • Web
  • [*] Desktop

Platform OS version
Ubuntu 24.10

How are you picking?

FilePickerResult? result = await FilePicker.platform.pickFiles(
  type: FileType.custom,
  allowedExtensions: ['parquet', 'csv', 'json', 'ndjson', 'jsonl'],
  dialogTitle: 'Select Dataset',
);

Details to reproduce the issue

  1. Go directly to the folder containing files with other extension - works fine
  2. Go back to parent folder
  3. Go into the previous folder again, now all files are selectable - bug is here

Error Log
No log was got.

Screenshots and/or video
Screenshot From 2025-01-13 22-40-29
Screenshot From 2025-01-13 22-40-06

Flutter Version details

Flutter 3.27.1 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 17025dd882 (4 weeks ago) • 2024-12-17 03:23:09 +0900
Engine • revision cb4b5fff73
Tools • Dart 3.6.0 • DevTools 2.40.2

[✓] Flutter (Channel stable, 3.27.1, on Ubuntu 24.10 6.11.0-13-generic, locale en_US.UTF-8)
    • Flutter version 3.27.1 on channel stable at /home/kelvin/Library/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 17025dd882 (4 weeks ago), 2024-12-17 03:23:09 +0900
    • Engine revision cb4b5fff73
    • Dart version 3.6.0
    • DevTools version 2.40.2

[!] Android toolchain - develop for Android devices (Android SDK version 35.0.0)
    • Android SDK at /home/kelvin/Library/AndroidSDK
    • Platform android-35, build-tools 35.0.0
    • ANDROID_SDK_ROOT = /home/kelvin/Library/AndroidSDK
    • Java binary at: /home/kelvin/Library/Java/OracleJDK-23.0.1/bin/java
    • Java version Java(TM) SE Runtime Environment (build 23.0.1+11-39)
    ✗ Android license status unknown.
      Run `flutter doctor --android-licenses` to accept the SDK licenses.
      See https://flutter.dev/to/linux-android-setup for more details.

[✓] Chrome - develop for the web
    • Chrome at google-chrome

[✓] Linux toolchain - develop for Linux desktop
    • Ubuntu clang version 19.1.1 (1ubuntu1)
    • cmake version 3.30.3
    • ninja version 1.12.1
    • pkg-config version 1.8.1

[!] Android Studio (not installed)
    • Android Studio not found; download from https://developer.android.com/studio/index.html
      (or visit https://flutter.dev/to/linux-android-setup for detailed instructions).

[✓] IntelliJ IDEA Ultimate Edition (version 2024.3)
    • IntelliJ at /home/kelvin/Application/JetBrains/idea
    • Flutter plugin version 83.0.4
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart

[✓] Proxy Configuration
    • HTTP_PROXY is set
    • NO_PROXY is *.zju.edu.cn,localhost,127.0.0.1,192.168.0.0/16,10.0.0.0/8,172.16.0.0/12,::1
    • NO_PROXY contains localhost
    • NO_PROXY contains 127.0.0.1
    • NO_PROXY contains ::1

[✓] Connected device (2 available)
    • Linux (desktop) • linux  • linux-x64      • Ubuntu 24.10 6.11.0-13-generic
    • Chrome (web)    • chrome • web-javascript • Google Chrome 131.0.6778.264

[✓] Network resources
    • All expected network resources are available.

Additional context

I think file_picker should switch to the latest file selecting dialog of Ubuntu instead of using the old one. The latest one looks like this:

Screenshot From 2025-01-13 22-47-55

The old file selecting dialog seems to be buggy (i'm not sure whether my understanding is correct), please consider switching

@Kelvinlby Kelvinlby added the new issue An issue that hasn't yet been seen from the maintainer label Jan 13, 2025
@Kelvinlby
Copy link
Author

And the file selected could still be received
Screenshot From 2025-01-13 23-05-17

@oploco
Copy link

oploco commented Jan 15, 2025

Estoy experimentando el mismo comportamiento en tu app y en un dispositivo con Android 7.
He recurrido a utilizar FileType.any como solución temporal con lógica condicional para la versión de Android. Esto puede ser útil para quienes se encuentren con el mismo problema.
`FilePickerResult? result;

if (Platform.isAndroid) {
  DeviceInfoPlugin deviceInfo = DeviceInfoPlugin();
  AndroidDeviceInfo androidInfo = await deviceInfo.androidInfo;
  int sdkInt = androidInfo.version.sdkInt;

  if (sdkInt <= 24) { // Android 7 o inferior (API 24)
    result = await FilePicker.platform.pickFiles(type: FileType.any);
  } else { // Android 8 o superior
    result = await FilePicker.platform.pickFiles(
      type: FileType.custom,
      allowedExtensions: ['json'],
    );
  }
} else { // iOS u otras plataformas
  result = await FilePicker.platform.pickFiles(
    type: FileType.custom,
    allowedExtensions: ['json'],
  );
}`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new issue An issue that hasn't yet been seen from the maintainer
Projects
None yet
Development

No branches or pull requests

2 participants