Adding an Image Asset Flutter

Allan Muturi
1 min readSep 17, 2022
Photo by Artur Shamsutdinov on Unsplash

Recently I have been fluttering and I want to share how one can add an Image asset on flutter

First create and asset folder in the same directory as the pubsec.yaml file. Inside the asset folder create an images folder.

A screenshot of assets directory

Inside the images folder add the images that you want to add in flutter.

Next step is to edit the pubsec.yaml file. Inside pubsec.yaml register your assets by adding the following lines

# To add assets to your application, add an assets section, like this:flutter:assets:- assets/images/imagename.jpg

If you have multiple images :

#incase of multiple images it is not a must to add the Image name
flutter:
assets:- assets/images/

Save the pubsec.yaml file

You can now use your image inside your flutter code.

Image.asset('assets/images/imagename.jpg')

It is a simple as that

Happy Coding 🥳 🥳 🎉

You can check out my twitter 🐦 and github 👨‍💻 for interesting projects.

--

--

Allan Muturi

Mobile, web developer and a mathematics and computer science graduate who likes to play with both software and hardware.