I am designing a widget that displays an image and a text on top of it.
In order to put the text widget on top of the image, I am using a Stack, however, as soon as I wrap the widgets with the stack, the bottom part of the image gets cut.
- Without
Stack(this is good):
Widget body() {
return Padding(
padding: const EdgeInsets.all(8.0),
child: ClipRRect(
borderRadius: BorderRadius.circular(8),
child: Container(
width: 160,
height: 200,
child: Image.network(
'https://picsum.photos/250?image=9',
fit: BoxFit.cover,
),
),
),
);
}
- With
Stack(not good as the bottom of the image gets cut):
Widget body() {
return Padding(
padding: const EdgeInsets.all(8.0),
child: ClipRRect(
borderRadius: BorderRadius.circular(8),
child: Container(
width: 160,
height: 200,
child: Stack(
children: [
Image.network(
'https://picsum.photos/250?image=9',
fit: BoxFit.cover,
),
Align(
alignment: Alignment.bottomLeft,
child: Text('Label'),
)
],
),
),
),
);
}
Any ideas why this is happening and how to address it?

