Why overflow: TextOverflow.visible is not working? I can’t fix it. I want if it overflow jumps to new line and shows all text. I think the problem is because card is wrapped with expanded but I need expanded because I want that card fill all available space. Can you help me?
Expanded(
flex: 2,
child: Card(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8.0),
),
color: const Color(0XFFB0ADE2),
margin: const EdgeInsets.symmetric(vertical: 5),
elevation: 0,
child: Padding(
padding:
const EdgeInsets.symmetric(vertical: 10, horizontal: 20),
child: Row(
children: <Widget>[
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
'text',
style: const TextStyle(
fontWeight: FontWeight.bold,
fontSize: 18,
),
),
Text(
'subText very very long sentence to fit in one row and text.overflow visible is not working properly',
overflow: TextOverflow.visible,
softWrap: true,
style: const TextStyle(
fontSize: 12,
),
),
],
),
],
),
),
),
),
4
Answers
Wrap the Text widget with a Flexible or Expanded widget to use a numbers of row > 1
This is the official doc https://flutter.dev/docs/development/ui/layout#lay-out-multiple-widgets-vertically-and-horizontally on how to arrange widgets.
You need to embed your
Column
in anExpanded
widget, otherwise it does not know how wide it can be:Just try wrapping
Column
withinExpanded
, now the Row’s children understands that it can take maximum width.Note: And if you want to limit the overflowed number of lines you can consider setting
maxLine
property to2
or3
of your choice.Code structure to follow:
Complete code:
You need to wrap with Expanded or Flexible widget.