This is a repost of an answer I wrote on Stack Overflow.
I originally wrote this answer when I was learning how to add images to my Flutter project. Check out the documentation, but in case you need a little more step-by-step help, keep reading.
1. Create an assets/images
folder
- This should be located in the root of your project, in the same folder as your
pubspec.yaml
file. - In Android Studio you can right click in the Project view
- You don’t have to call it
assets
orimages
. You don't even need to makeimages
a subfolder. Whatever name you use, though, is what you will register in thepubspec.yaml
file.
2. Add your image to the new folder
- You can just copy your image into
assets/images
. The relative path oflake.jpg
, for example, would beassets/images/lake.jpg
.
3. Register the assets folder in pubspec.yaml
- Open the
pubspec.yaml
file that is in the root of your project. - Add an
assets
subsection to the…