Flutter Package Reading its Own Assets Flutter Package Reading its Own Assets dart dart

Flutter Package Reading its Own Assets


I got a solution. Even though my package was trying to load its own asset, it still had to specify itself as the location.

Here is how my_package loads an image asset (specifying the package), uses it in a widget, and that widget is easily used by outside apps.

Image.asset(AssetImage("assets/splash.png").assetName, package: 'my_package',);


This is a bit late, but another solution can be:

Image.asset('packages/<package_name>/assets/splash.png'); 


I encountered this problem and took a lot of time before it was resolved.The solution was to downgrade to a previous version (git checkout v1.5.4-hotfix.2)