Reputation: 81
My image is unable to resize. Firstly I have put the background in the container widget. After that, I have put the logo image in the center widget using Image.assets. The main problem is that the size of the image is resizing according to the height and width. Currently, I am coding in the flutter framework using dart language.
I am doing coding in Android Studio.
@override
Widget build(BuildContext context) {
return new MaterialApp(
debugShowCheckedModeBanner: false,
home: new Scaffold(
body: new Stack(
children: <Widget>[
new Container(
decoration: new BoxDecoration(
image: new DecorationImage(
image: new AssetImage("assets/imgs/home_bg.png"),
fit: BoxFit.cover,
)
),
),
new Center(
child: Image.asset("assets/imgs/home_logo.png",height: 300,width:300,),
)
],
),
),
);
No error messages are showing. Then also the image is not resizing.
Upvotes: 8
Views: 17719
Reputation: 1483
Container(
height: 20.0,
width: 20.0,
decoration: BoxDecoration(shape: BoxShape.circle, color: Colors.red),
child: Image.asset(
'assets/[email protected]',
),
);
Upvotes: 1
Reputation: 1028
You can use it like-
new Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
mainAxisSize: MainAxisSize.max,
children: <Widget>[
new Expanded(child: new Image.asset(
"assets/imgs/home_logo.png",height: 300,width:300,
),
),
]
)
Upvotes: 2
Reputation: 109
You can also try wrapping the Image in a Flexible located in a Column wich is wrapped in a Container with the dimensions you need
Upvotes: 0
Reputation: 14315
body: Center(
child: SizedBox(
width: 100.0,
height: 100.0,
child: Image.network(
"https://th.thgim.com/opinion/op-ed/article22695424.ece/alternates/FREE_300/9thscience"),
),
))
Upvotes: 4