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.28k stars 625 forks source link

Web:Uncaught Unsupported operation: Platform._operatingSystem #1484

Open mokanus opened 2 months ago

mokanus commented 2 months ago

Describe the bug The local operation is perfect, and when I use Flutter run -- release, it is also possible. However, when deploying and accessing Flutter build web, errors may occur

Platform

Platform OS version MacOS:14.2.1 (23C71) Chrome: 123.0.6312.87(正式版本) (x86_64)

How are you picking? I just trigger by one button.Just like: image then: image

After testing this logic, I found an error occurring in the part where the file retrieval is opened, which is the location shown in my screenshot. The issue is that when I click the button, there is no response, and the console displays this error log.

Error: main.dart.js:5168 Uncaught Unsupported operation: Platform._operatingSystem at Object.c (http://38.47.108.163/main.dart.js:5168:19) at Object.b00 (http://38.47.108.163/main.dart.js:9314:15) at Object.b01 (http://38.47.108.163/main.dart.js:9346:16) at http://38.47.108.163/main.dart.js:106263:22 at a. [as yG] (http://38.47.108.163/main.dart.js:30:36) at http://38.47.108.163/main.dart.js:106270:24 at a. [as aQc] (http://38.47.108.163/main.dart.js:30:36) at Object.aVD (http://38.47.108.163/main.dart.js:10949:6) at http://38.47.108.163/main.dart.js:106298:23 at a. [as aPV] (http://38.47.108.163/main.dart.js:27:35)

my code is very simple. image


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

**Error Log**

main.dart.js:5168 Uncaught Unsupported operation: Platform._operatingSystem at Object.c (http://38.47.108.163/main.dart.js:5168:19) at Object.b00 (http://38.47.108.163/main.dart.js:9314:15) at Object.b01 (http://38.47.108.163/main.dart.js:9346:16) at http://38.47.108.163/main.dart.js:106263:22 at a. [as yG] (http://38.47.108.163/main.dart.js:30:36) at http://38.47.108.163/main.dart.js:106270:24 at a. [as aQc] (http://38.47.108.163/main.dart.js:30:36) at Object.aVD (http://38.47.108.163/main.dart.js:10949:6) at http://38.47.108.163/main.dart.js:106298:23 at a. [as aPV] (http://38.47.108.163/main.dart.js:27:35)


**Flutter Version details**

Flutter 3.19.5 • channel stable • https://github.com/flutter/flutter.git Framework • revision 300451adae (12 天前) • 2024-03-27 21:54:07 -0500 Engine • revision e76c956498 Tools • Dart 3.3.3 • DevTools 2.31.1

used: file_picker: ^8.0.0+1

mokanus commented 2 months ago

I fixed by clean cache.

omensight commented 2 months ago

Is there a specific reason for this to happen? I can pick files without any problem in debug mode but when I build the project for flutter web it gives me this error.

omensight commented 2 months ago

I see that when I specify the type it stops working in production: FilePickerResult? result = await FilePicker.platform.pickFiles( dialogTitle: LocaleKeys.pickBranchLogo.tr(), type: FileType.image, ); It works well without specifying the type.