Reputation: 961
my widget text Wrap inside Expanded, row, and Column
return Container(
child: Expanded(
flex: 9,
child: GestureDetector(
onTap: () {
// .......
},
child: Container(
color: Colors.transparent,
child: Row(
children: <Widget>[
Padding(
padding: EdgeInsets.only(top: 15, bottom: 15),
child: Container(
width: 2,
color: Color(0XFF2B9FDC),
)),
Padding(
padding: EdgeInsets.only(left: 15),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text( item.name,
overflow: TextOverflow.ellipsis,
maxLines: 2,
),
Text(item.catgeory),
Text(item.price,
style: TextStyle(color: Colors.red),
),
],
),
),
],
),
),
),
),
);
I got error : Another exception was thrown: A RenderFlex overflowed by 7.3 pixels on the right.
AnyOne can help?
Upvotes: 0
Views: 1154
Reputation: 8239
Just wrap your container
with Expanded
and use flex property as per your design and let me know its working or not
return Expanded(
child: Container(
child: GestureDetector(
onTap: () {
// .......
},
child: Container(
color: Colors.transparent,
child: Row(
children: <Widget>[
Padding(
padding: EdgeInsets.only(top: 15, bottom: 15),
child: Container(
width: 2,
color: Color(0XFF2B9FDC),
)),
Padding(
padding: EdgeInsets.only(left: 15),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text( item.name,
overflow: TextOverflow.ellipsis,
maxLines: 2,
),
Text(item.catgeory),
Text(item.price,
style: TextStyle(color: Colors.red),
),
],
),
),
],
),
),
),
),
);
Upvotes: 3
Reputation: 80934
Change this:
Text(
item.name,
overflow: TextOverflow.ellipsis,
maxLines: 2,
),
into this:
Text(
item.name,
softWrap : true,
maxLines: 2,
),
softWrap → bool
Whether the text should break at soft line breaks
Upvotes: 1