I don’t know why I set in my container or Image.file the height and width with a BoxFit.fill and it’s not working
Stack(
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: [
[...]
Padding(
padding: ...,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: [
[...]
Container(
height: 150,
width: MediaQuery.of(context).size.width,
color: Colors.red,
child: Image.file(
File(...),
fit: BoxFit.fill,
),
)
],
),
),
],
),
[...]
],
),
//////////// UPDATE :
I want that my image width cover all the container red. But i tried in differents ways and its not working :
Container(
height: 150,
width: MediaQuery.of(context).size.width,
color: Colors.red,
child: FittedBox(
fit: BoxFit.fill,
child: Image.file(
File(...),
),
),
),
Container(
height: 150,
width: MediaQuery.of(context).size.width,
color: Colors.red,
child: Image.file(
File(...),
height: 150,
width: MediaQuery.of(context).size.width,
fit: BoxFit.fill,
),
),
Container(
height: 150,
width: MediaQuery.of(context).size.width,
decoration: BoxDecoration(
color: Colors.red,
image: DecorationImage(
image: FileImage(
File(...),
),
fit: BoxFit.cover,
),
),
),
4
You can try this code
Container(
height : 200.0,
width : 200.0,
decoration: const BoxDecoration(
image: DecorationImage(
image: AssetImage(
'assets/images/bg.png',
),
fit: BoxFit.cover,
),
color:Colors.red,),
child: Text("Hello World"),
),
I hope this can work for you. This will show your image inside your red container.
0