image in flutter code example
Example 1: flutter image asset
flutter:
assets:
- graphics/
Image(image: AssetImage('graphics/background.png'))
Example 2: image in container flutter
Container(
height: 120.0,
width: 120.0,
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage(
'assets/assets/alucard.jpg'),
fit: BoxFit.fill,
),
shape: BoxShape.circle,
),
)
Example 3: flutter url image
Image.network('https://picsum.photos/250?image=9')
Example 4: flutter asset image not showing
flutter:
uses-material-design: true
assets:
- assets/
class _UserLoginState extends State<UserLogin> {
@override
Widget build(BuildContext context) {
return Scaffold(
body: Stack(
children: <Widget>[
Image(image: AssetImage("assets/christmas.jpeg"),
fit: BoxFit.cover,
],
)
);
}
}
Example 5: flutter image load
Image.asset(name) is essentially Image(image: AssetImage(name)),
Image.file(path) is essentially Image(image: FileImage(File(path))),
Image.network(url) is essentially Image(image: NetworkImage(url)),
Image.memory(list) is essentially Image(image: MemoryImage(list))
Example 6: how to display an image in flutter using its filepath
Image.file(File(path))