miguelpruivo / flutter_file_picker

File picker plugin for Flutter, compatible with mobile (iOS & Android), Web, Desktop (Mac, Linux, Windows) platforms with Flutter Go support.
MIT License
1.35k stars 675 forks source link

Web: FIlePickerResult.xFiles crashes when withData: false #1544

Closed eggzotic closed 3 months ago

eggzotic commented 4 months ago

Describe the bug After selecting file(s) on web, any access to the xFiles property of the result results in:

Error
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/errors.dart 296:3       throw_
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart 586:18  nullCheck
packages/file_picker/src/platform_file.dart 79:34                                 get xFile
packages/cluster_view/widget/object/bucket_list_ui.dart 231:53                    <fn>
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 45:50                <fn>
dart-sdk/lib/async/zone.dart 1661:54                                              runUnary
dart-sdk/lib/async/future_impl.dart 163:18                                        handleValue
dart-sdk/lib/async/future_impl.dart 847:44                                        handleValueCallback
dart-sdk/lib/async/future_impl.dart 876:13                                        _propagateToListeners
dart-sdk/lib/async/future_impl.dart 652:5                                         [_completeWithValue]
dart-sdk/lib/async/future_impl.dart 722:7                                         callback
dart-sdk/lib/async/schedule_microtask.dart 40:11                                  _microtaskLoop
dart-sdk/lib/async/schedule_microtask.dart 49:5                                   _startMicrotaskLoop
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 181:7                <fn>

Similarly, attempting to stick with the files property, and accessing the converter PlatformFile.xFile also crashes like above.

By comparison, on MacOS (native), the xFiles properties are accessible. Also, using withData: true works on both platforms (web & other).

I intend to pass the xFile objects to other code which will handle opening/reading the files (sometimes large!) so do not want the data pre-read. Is there a workaround or fix known for this?

Platform

Platform OS version Chrome, MacOS, latest

How are you picking?

pickerResult =
   await FilePicker.platform.pickFiles(
     dialogTitle: "Select file(s) for upload",
     allowMultiple: true,
     withData: false,
     allowCompression: false,
     withReadStream: false,
   );
   debugPrint("Filepicker closed");
   if (pickerResult == null || pickerResult.files.isEmpty) return;

Details to reproduce the issue Provide all the details to reproduce the issue.

Error Log Please, post the full console log of your issue, if applicable.

Screenshots and/or video If applicable, add screenshots or video to help explain your problem.

Flutter Version details

flutter doctor -v
[✓] Flutter (Channel stable, 3.22.2, on macOS 14.5 23F79 darwin-arm64, locale en-GB)
    • Flutter version 3.22.2 on channel stable at /Users/richard/development/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 761747bfc5 (5 weeks ago), 2024-06-05 22:15:13 +0200
    • Engine revision edd8546116
    • Dart version 3.4.3
    • DevTools version 2.34.3

[✗] Android toolchain - develop for Android devices
    ✗ Unable to locate Android SDK.
      Install Android Studio from: https://developer.android.com/studio/index.html
      On first launch it will assist you in installing the Android SDK components.
      (or visit https://flutter.dev/docs/get-started/install/macos#android-setup for detailed instructions).
      If the Android SDK has been installed to a custom location, please use
      `flutter config --android-sdk` to update to that location.

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

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

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

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

[✓] Connected device (3 available)
    • macOS (desktop)                 • macos                 • darwin-arm64   • macOS 14.5 23F79 darwin-arm64
    • Mac Designed for iPad (desktop) • mac-designed-for-ipad • darwin         • macOS 14.5 23F79 darwin-arm64
    • Chrome (web)                    • chrome                • web-javascript • Google Chrome 126.0.6478.127

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

! Doctor found issues in 2 categories.
github-actions[bot] commented 4 months ago

This issue is stale because it has been open for 7 days with no activity.

github-actions[bot] commented 3 months ago

This issue was closed because it has been inactive for 14 days since being marked as stale.