yekeskin / flutter_avif

A flutter plugin to view and encode avif images.
https://pub.dev/packages/flutter_avif
MIT License
53 stars 15 forks source link

package javascript load error when deployed with firebase hosting #42

Closed thunderbug1 closed 9 months ago

thunderbug1 commented 10 months ago

Not sure to better post this here or for firebase-hosting, but this is the package where I get the error (probably because it is the only one the brings it's own javascript) I think others will probably run into the same problem.

I use flutter_avif in a webapp and deploy with firebase hosting. When I deploy my flutter webapp and open it I get this error, the package is installed

GET https://mywebsite.com/packages/flutter_avif_web/web/avif_encoder.loader.js net::ERR_ABORTED 404 (Not Found)

I found out that "flutter build web" puts the packages folder inside of the assets folder, so this url is reachable:

https://mywebsite.com/assets/packages/flutter_avif_web/web/avif_encoder.loader.js

I am not sure how to best fix this. I tried to add this workaround in the firebase.json but it didn't help either: "rewrites": [ { "source": "/packages/", "destination": "/assets/packages/" } ]

yekeskin commented 10 months ago

The issue related to how the plugin loads javascript assets. Should be fixed with 1ff520438a017e0c1c0938737fba19f82720a887. Can you try if it is working for you?

You can try it by adding the following lines to your pubspec.yaml

dependency_overrides:
  flutter_avif_web:
      git:
        url: 'https://github.com/yekeskin/flutter_avif.git'
        path: 'flutter_avif_web'
thunderbug1 commented 10 months ago

The issue related to how the plugin loads javascript assets. Should be fixed with 1ff5204. Can you try if it is working for you?

You can try it by adding the following lines to your pubspec.yaml

dependency_overrides:
  flutter_avif_web:
      git:
        url: 'https://github.com/yekeskin/flutter_avif.git'
        path: 'flutter_avif_web'

Perfect thanks! The fix works :)

yekeskin commented 9 months ago

The fix is included in version 2.3.0.