My image cannot be resized. First, I added a background image to a container widget. Then, I placed the logo image in the center widget using Image.asset
. The main issue is that the image size is being resized according to its height and width. Currently, I am coding in the Flutter framework using the Dart language.
I am 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,
),
),
],
),
),
);
}
There are no error messages displayed, yet the image is not resized.
Solution
Wrap the image widget with an Expanded
widget so that the width and height settings work properly.
Expanded(
child: Image.asset(
"assets/imgs/home_logo.png",
height: 300,
width: 300,
),
),