text is taking unnecessary height inside column, (Samantha & Angelica for example)
Screenshot with inspecter widget enabled
This is the code of the screen
return GestureDetector(
onTap: tap,
child: Container(
margin: const EdgeInsets.only(
left: kDefaultPadding,
top: kDefaultPadding / 2,
bottom: kDefaultPadding * 2),
width: size.width * 0.4,
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Image.asset(image),
Container(
// width: size.width * 0.4,
padding: const EdgeInsets.all(kDefaultPadding / 2),
decoration: BoxDecoration(color: Colors.white, boxShadow: [
BoxShadow(
offset: Offset(0, 0),
blurRadius: 50,
color: kPrimaryColor.withOpacity(0.15))
]),
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
child: Text(
"${title.toUpperCase()}n",
style: TextStyle(
fontSize: fontSize,
overflow: TextOverflow.ellipsis),
),
),
Text("$$price",
style: TextStyle(
fontSize: fontSize - 2,
color: kPrimaryColor.withOpacity(0.8))),
],
),
Text(
country,
style: TextStyle(
fontSize: fontSize - 2,
color: kPrimaryColor.withOpacity(0.8)),
)
],
))
],
),
));
I use a Column with two items,Row and A Text(Which contains the country), and inside the Row I have to Items the owner and the Price
I tried
mainAxisSize: MainAxisSize.min
And it’s not working
2
Answers
You can give it a fixed size (or calculate it depending on the screen height) or you just wrap your Row with a InstrinctHeight, but this is kinda expensive, from the docs:
The text widget is taking exactly the amount of height is needs for the text that you specified. Since you are inserting a newline character
n
appended to the title, it will clearly take two lines instead of one.Change this:
To this: