Including assets in a Flutter package
A guide for package developers
If you are coming to this page wanting to know how to include images, fonts, or other assets in your Flutter app, then you might be in the wrong place. Check out one of these other articles for help:
- How to use a custom font in a Flutter app
- How to include images in your Flutter app
- Reading a text file from assets in Flutter
- Flutter documentation: Adding assets and images
The guide below is for package developers who need to include assets in their package.
Where to put the assets
So you have an image or font or something that you want to make available to the app developers who use your package. Where do you put it?
One choice is to put it in the lib/ folder.
Anything in the lib/ folder will get automatically bundled with the app. Those assets will be available to anyone who uses your package. As the package developer, you don’t even need to declare those assets in pubspec.yaml if you are not using them yourself. They’ll still be bundled…