I have nested rows using this code:
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Row(
children: <Widget>[
Icon(Icons.fiber_manual_record),
Text(
'the text in the first row',
),
],
),
Row(
children: <Widget>[
Icon(Icons.fiber_manual_record),
Text(
'the text in the second row',
),
],
),
],
)
When there is space, I want the rows to be side by side (current behavior):
Currently, when it overflows, the text gets cut off like this:
Is there a way to force the second row onto a new line when there's no space, so it looks like this?
A widget that displays its children in multiple horizontal or vertical runs. A Wrap lays out each child and attempts to place the child adjacent to the previous child in the main axis, given by direction, leaving spacing space in between.
softWrap. Whether the text should break at soft line breaks. If false, the glyphs in the text will be positioned as if there was unlimited horizontal space.
It is an important feature for any text editor which breaks the section of a particular text to fit into multiple sections of lines where possible. It is used to fit the content in the width of a text document. In Tkinter, we can wrap the words or chars in the text widget using the wrap property.
Try this! It worked for me.
new Flexible(child: new Text('Auto wrap'))
Something on these lines will work:
Wrap(
direction: Axis.horizontal,
children: <Widget>[
Wrap(
children: <Widget>[
Icon(Icons.fiber_manual_record),
Text(
'the text ',
),
],
),
Wrap(
children: <Widget>[
Icon(Icons.fiber_manual_record),
Text(
'more the text in the first row',
),
],
),
Wrap(
children: <Widget>[
Icon(Icons.fiber_manual_record),
Text(
'the text in the second row',
),
],
),
Wrap(
children: <Widget>[
Icon(Icons.fiber_manual_record),
Text(
'more text in the second row',
),
],
),
Wrap(
children: <Widget>[
Icon(Icons.fiber_manual_record),
Text(
'the text in the third row',
),
],
),
],
)
Row(
children: [
Checkbox(
onChanged: (bool value) {},
value: true,
),
Flexible(
child: RichText(
strutStyle: StrutStyle(height: 1.4),
softWrap: true,
text: TextSpan(style: TextStyle(fontSize: 12, color: ColorUtil.hexToColor("#999999")), children: <InlineSpan>[
TextSpan(text: "ฉันได้อ่านและยอมรับ "),
TextSpan(text: "ฉันได้อ่านและยอมรับ "),
TextSpan(
text: "สัญญาการให้บริการ & ข้อตกลงความเป็นส่วนตัว",
style: TextStyle(color: ColorUtil.hexToColor("#666666")),
recognizer: TapGestureRecognizer()
..onTap = () {
Navigator.pushNamed(context, "/profile/terms_policy");
}),
]),
),
)
],
),
this work for me. Wrap with Flexible
If you wrapped Text
widget with Padding
adding Flexible
around Padding
do the trick.
Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Icon(
Icons.check,
color: Colors.green,
),
SizedBox(
width: 16,
),
Flexible(
child: Padding(
padding: const EdgeInsets.fromLTRB(0, 8, 0, 0),
child: Text(
'Some text',
style: TextStyle(
fontSize: 18, color: Colors.white),
),
),
),
],
),
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With