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 672 forks source link

Error LateInitializate FilePicker.platform.pickFiles() web production #1602

Open Felixmda opened 1 month ago

Felixmda commented 1 month ago

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 A clear and concise description of what the bug is. If the issue happens to be on Android, please make sure that it also happens with a different device/simulator and/or version.

Platform

Platform OS version What version did it happen? 8.1.2

How are you picking?


Please, post the snippet here
``` FilePickerResult? result = await FilePicker.platform.pickFiles();

Error LateInitializate class in web production, in local dev no exists error. 

**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**
Please, post the output of your `flutter doctor -v`, preferably, while running the issued device/simulator.

**Additional context**
Add any other context about the problem here.
pahtz commented 1 month ago

This problem goes away if I turn off optimizations i.e., flutter build web --dart-define=Dart2jsOptimization=00

        await FilePicker.platform.pickFiles(withData: true);

Error on Chrome Windows and Safari iOS: LateInitializationError: Field '_instance' has not been initialized.

$ flutter doctor -v [✓] Flutter (Channel stable, 3.22.2, on IDX GNU/Linux 6.1.100+, locale en_US.UTF-8) • Flutter version 3.22.2 on channel stable at /home/user/flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision 761747bfc5 (4 months ago), 2024-06-05 22:15:13 +0200 • Engine revision edd8546116 • Dart version 3.4.3 • DevTools version 2.34.3

Using idx.google.com to develop then deploy to Firebase hosting.

0x456d7265 commented 1 month ago

I have the same problem. Here is the log in Chrome Dev Console

main.dart.js:5896 Uncaught Error: LateInitializationError: Field '_instance' has not been initialized.
    at Object.d (main.dart.js:5896:19)
    at bag.bS (main.dart.js:64563:21)
    at Object.c1y (main.dart.js:12962:20)
    at Object.c1z (main.dart.js:12963:16)
    at main.dart.js:151013:14
    at byt.a (main.dart.js:7285:63)
    at byt.$2 (main.dart.js:64805:14)
    at bxh.$1 (main.dart.js:64799:21)
    at arj.G_ (main.dart.js:66001:33)
    at bgh.$0 (main.dart.js:65273:11)
github-actions[bot] commented 1 month ago

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

b14cknc0d3 commented 1 month ago

Any update?

github-actions[bot] commented 3 weeks ago

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

chebyshevvv commented 3 weeks ago

async method is needed.

ArbazSparkoSol commented 3 weeks ago

Experiencing the same issue here. When I was running it locally, It was running fine. But when I deployed my project to production on firebase hosting. It started giving the above error.

b14cknc0d3 commented 3 weeks ago

Flutter clean and push again solved!

abhishekhugetech commented 2 weeks ago

was facing something similar and found this out

xSuperMu commented 2 weeks ago

I'm facing the same problem. it's not working on production.

file_picker: ^8.1.3

github-actions[bot] commented 1 week ago

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

Kristijan505 commented 1 week ago

Issue is still here on 8.1.4

xSuperMu commented 6 days ago

I'm Still facing the same problem. it's not working on production.

file_picker: ^8.1.4

Kristijan505 commented 6 days ago

Got it to work on production by setting version strictly to 8.1.0.

file_picker: 8.1.0