7. Flutter - Images & Assets

Image Widget:

Image() // widget

image: // property of the image widget


Network Images (Using images on internet):

Image(

image: NetworkImage('IMAGEURL'),

)


Asset Images (Using images on the project source folders):

1. Create a new image folder in project. Maybe call it "assets"

2. Add images

3. Edit pubspec.yaml file to use source images. Find assets section.

assets:
- assets/doge1.png
- assets/doge2.png
- assets/doge3.png

// If have too much images. Just reference the "assets" folder by itself only. Then any image inside it can be used.


Image(

image: AssetImage('assets/doge1.png'),

)


Example of Image Widget being used:

body: Center(
child: Image(
image: AssetImage('assets/doge2.png'),
),
),


Shortcuts to asset/network images:

Image.asset('URL')

Image.network('URL')

Comments

Popular posts from this blog

2. FreeCodeCamp - Dynamic Programming - Learn to Solve Algorithmic Problems & Coding Challenges

20. Data Analytics - Analyze Data to Answer Questions - Week 1

3. Algorithms - Selection Sort