Show image in Flutter

 



Load image from Asset

Image.asset("assets/images/blogcover.jpeg",

              height: 150, width: 150, fit: BoxFit.cover)


Image from https://knowyourmeme.com/

Crashed?????



Yes you have to add an image on pubspec.yaml file for more detail visit: https://flutter.dev/docs/development/ui/assets-and-images


Load image from URL

Image.network(
'http://www......png',
height: 150,
width: 150,
fit: BoxFit.cover),

To set image round we have multiple options


 CircleAvatar with border
CircleAvatar(
radius: 55, //for border
backgroundColor: Colors.red, //for border width
child: CircleAvatar(
radius: 50,
backgroundImage: AssetImage("assets/images/blogcover.jpeg"),
),
),
Container with BoxDecoration
Container(
width: 150,
height: 150,
decoration: BoxDecoration(
shape: BoxShape.circle,
border: Border.all(color: Colors.black, width: 2),
image: DecorationImage(
image: AssetImage("assets/images/blogcover.jpeg"),
fit: BoxFit.fill),
),
)


Thanks for reading, Happy Coding 👨‍💻

Popular posts from this blog

Frame vs bounds in Swift

Property wrapper in Swift

DateFomatter in Swift