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.33k stars 664 forks source link

LateInitializationError: Field '_instance' has not been initialized. on Flutter build web #1616

Open EduirBR opened 2 days ago

EduirBR commented 2 days ago

https://github.com/user-attachments/assets/ab1022d4-5f86-471a-8430-21f438a5f85f

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

using any browser

How are you picking?


  FilePickerResult? result = await FilePicker.platform.pickFiles(
      type: FileType.custom,
      allowedExtensions: ['jpg', 'jpeg', 'png'],
      allowMultiple: false);

  if (result != null) {
    PlatformFile file = result.files.first;
    Uint8List? imageBytes;
    ...
    }

Details to reproduce the issue

flutter build web then run your app and click the picker button

Error Log main.dart.js:3304 Uncaught Error: LateInitializationError: Field 'instance' has not been initialized. at Object.f (main.dart.js:3304:19) at am2.be (main.dart.js:35999:21) at Object.aNd (main.dart.js:27213:20) at Object.aNe (main.dart.js:27214:16) at main.dart.js:7415:31 at auC.a (main.dart.js:4655:63) at auC.$2 (main.dart.js:36229:14) at Object.H (main.dart.js:4641:10) at Object.aUA (main.dart.js:7417:10) at Object.az (main.dart.js:7412:21)

Screenshots and/or video

image

Flutter Version details [√] Flutter (Channel stable, 3.24.3, on Microsoft Windows [Versi¢n 10.0.22631.4317], locale es-VE) • Flutter version 3.24.3 on channel stable at C:\flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision 2663184aa7 (5 weeks ago), 2024-09-11 16:27:48 -0500 • Engine revision 36335019a8 • Dart version 3.5.3 • DevTools version 2.37.3

[√] Windows Version (Installed version of Windows is version 10 or higher)

[√] Android toolchain - develop for Android devices (Android SDK version 35.0.0-rc3) • Android SDK at C:\Users\Eduir\AppData\Local\Android\Sdk • Platform android-34, build-tools 35.0.0-rc3 • ANDROID_HOME = C:\Users\Eduir\AppData\Local\Android\Sdk • Java binary at: C:\Program Files\Android\Android Studio\jbr\bin\java • Java version OpenJDK Runtime Environment (build 17.0.9+0--11185874) • All Android licenses accepted.

[√] Chrome - develop for the web • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe

[√] Visual Studio - develop Windows apps (Visual Studio Community 2022 17.11.2) • Visual Studio at C:\Program Files\Microsoft Visual Studio\2022\Community • Visual Studio Community 2022 version 17.11.35222.181 • Windows 10 SDK version 10.0.22621.0

[√] Android Studio (version 2023.2) • Android Studio at C:\Program Files\Android\Android Studio • 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.9+0--11185874)

[√] VS Code (version 1.94.2) • VS Code at C:\Users\Eduir\AppData\Local\Programs\Microsoft VS Code • Flutter extension version 3.98.0

[√] Connected device (3 available) • Windows (desktop) • windows • windows-x64 • Microsoft Windows [Versi¢n 10.0.22631.4317] • Chrome (web) • chrome • web-javascript • Google Chrome 129.0.6668.101 • Edge (web) • edge • web-javascript • Microsoft Edge 129.0.2792.89

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

• No issues found!

Additional context not other context just not working for flutter web on the release, it works on dev with flutter run and with debuger but after getting the build its doesnt works

Aadv1k commented 1 day ago

I second this. Getting the same issue here as well, I can't even create a hello-world as it it throws the error.

// ...
onPressed: () async {
    FilePickerResult? result =
        await FilePicker.platform.pickFiles();
},
// ...

However running flutter clean seem to have worked, but I am not sure if this was a bug or a misconfiguration on my part