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

FilePicker.platform.pickFiles won't return #1687

Open
3 tasks
ChurikiTenna opened this issue Jan 22, 2025 · 5 comments
Open
3 tasks

FilePicker.platform.pickFiles won't return #1687

ChurikiTenna opened this issue Jan 22, 2025 · 5 comments
Labels
feature-candidate This issue might result in a feature to be implemented

Comments

@ChurikiTenna
Copy link

ChurikiTenna commented Jan 22, 2025

Before creating an issue, make sure that you are on the latest file_picker version and that there aren't already any similar opened inssues. Also, check if it isn't described on the Wiki, specially on Troubleshooting page.

Also, sometimes a simple flutter clean and flutter build again with latest file_picker version, may end up by fixing cached issues, so I encourage you to first do so.

Describe the bug
This code won't print pickPdfText.result after picking a pdf file. it stuck with FilePicker.platform.pickFiles, and the window become inoperable.

debugPrint('pickPdfText');
      var result = await FilePicker.platform.pickFiles(
          allowMultiple: true,
          type: FileType.custom,
          allowedExtensions: [
            'pdf',
          ]);
      debugPrint('pickPdfText.result $result');

Platform

  • Android
  • iOS
  • [TRUE] Web
  • Desktop

Platform OS version
8.1.7

How are you picking?

 var result = await FilePicker.platform.pickFiles(
          allowMultiple: true,
          type: FileType.custom,
          allowedExtensions: [
            'pdf',
          ]);

Details to reproduce the issue
Try above code on web debug build.

Error Log
No log.

Screenshots and/or video
None.

Flutter Version details
% flutter doctor -v
[✓] Flutter (Channel stable, 3.27.2, on macOS 15.1.1 24B91 darwin-arm64, locale ja-JP)
• Flutter version 3.27.2 on channel stable at /Users/tenna/developer/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 68415ad1d9 (9 days ago), 2025-01-13 10:22:03 -0800
• Engine revision e672b006cb
• Dart version 3.6.1
• DevTools version 2.40.2

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
• Android SDK at /Users/tenna/Library/Android/sdk
• Platform android-35, build-tools 34.0.0
• Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 17.0.11+0-17.0.11b1207.24-11852314)
• All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 16.2)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 16C5032a
• CocoaPods version 1.15.2

[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2024.1)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 17.0.11+0-17.0.11b1207.24-11852314)

[✓] VS Code (version 1.96.2)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.102.0

[✓] Connected device (6 available)
• Sota’s iPad (mobile) • 00008030-0011253134E0C02E • ios • iOS 17.6.1 21G93
• tenna’s iphone15 (mobile) • 00008120-00120DDA1E10A01E • ios • iOS 18.3 22D5040d
• Tenna’s iPad (mobile) • d1802c9bcfe7b9b836383ca90361f9c15180f21e • ios • iOS 17.7.2 21H221
• macOS (desktop) • macos • darwin-arm64 • macOS 15.1.1 24B91
darwin-arm64
• Mac Designed for iPad (desktop) • mac-designed-for-ipad • darwin • macOS 15.1.1 24B91
darwin-arm64
• Chrome (web) • chrome • web-javascript • Google Chrome 131.0.6778.265
! Error: Browsing on the local area network for Tenna’s iPad (2). Ensure the device is unlocked and attached with a cable or
associated with the same local area network as this Mac.
The device must be opted into Developer Mode to connect wirelessly. (code -27)
! Error: Browsing on the local area network for Tenna’s iPhone11. Ensure the device is unlocked and attached with a cable or
associated with the same local area network as this Mac.
The device must be opted into Developer Mode to connect wirelessly. (code -27)

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

• No issues found!

@ChurikiTenna ChurikiTenna added the new issue An issue that hasn't yet been seen from the maintainer label Jan 22, 2025
@binoypatel
Copy link

+1
In my case result is null on web

@binoypatel
Copy link

Found a solution from https://github.com/miguelpruivo/flutter_file_picker/wiki/FAQ (How do I access the path on Web?)

Not a bug.

Thanks,
Binoy

@navaronbracke
Copy link
Collaborator

The path on web is not available, as you cannot access the file system in web apps.
You can access the bytes directly on the web.

@topongo
Copy link

topongo commented Feb 16, 2025

i'm experiencing the same issue: looking at the code (specifically here) i think the problem is that if the file picker window loses focus it will return null before completing.
if you have a slightly exotic window manager (hyprland in my case), the window could not be receiving focus right away, making it fail silently.
my proposal is to drop this part of the code entirely, since is up to the user to cancel the operation: until the picker window is open the process shouldn't end, for the sake of consistency.

if i didn't understand the use of that part of code i'd be happy to be corrected and change my opinion. but as for now i think this specific behavior is not intended.

i'm using this constructor btw

FilePicker.platform.pickFiles(allowMultiple: true, withReadStream: true, withData: false);

commenting this line makes it work as intended.

@navaronbracke
Copy link
Collaborator

@topongo That line looks suspicius yes, because the event listener triggers when any focus event happens (so focus or unfocus).

It should probably ony trigger for unfocus events?

@navaronbracke navaronbracke added feature-candidate This issue might result in a feature to be implemented and removed new issue An issue that hasn't yet been seen from the maintainer labels Feb 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-candidate This issue might result in a feature to be implemented
Projects
None yet
Development

No branches or pull requests

4 participants