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

Crash web with web-view-renderer HTML #1543

Closed mennovanhout closed 4 months ago

mennovanhout commented 4 months 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 This bug only occurs with a production build, not with flutter RUN. After building an exception is thrown when trying to open the file picker.

Platform

Platform OS version Windows 11, Newest google Chrome, newest flutter 3.22.0

How are you picking?

void _pickBackgroundImage() async {
    if (_backgroundImage != null || _backgroundImageUrl != null) {
      setState(() {
        _backgroundImage = null;
        _backgroundImageUrl = null;
      });
      return;
    }

    FilePickerResult? result = await FilePicker.platform
        .pickFiles(type: FileType.image, allowCompression: false);

    if (result != null) {
      setState(() {
        _backgroundImage = result.files.single.bytes;
      });
    }
  }

Details to reproduce the issue During debugging this works perfectly fine in the browser, however when building with the command: flutter build web --web-renderer html --no-tree-shake-icons it doesn't work, an unknown javascript exception is thrown.

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

Screenshots and/or video image

Flutter Version details 3.22.0

Additional context Add any other context about the problem here.

mennovanhout commented 4 months ago

Clsing, seems to be an issue that's solved with flutter clean