在 flutter 中,如何中断文本并将其保留在容器内的下一行?
SizedBox(
height: 100,
width: 320,
child: Text(
domaindesc,
softWrap: true,
overflow: TextOverflow.ellipsis,
style: GoogleFonts.roboto(textStyle: ktextstyle),
),
);
如果您的意思是在同一文本段落中创建一个新行?添加这个' ' 你想要一个新行开始的地方。
此外,如果您想更改文本不同部分的字体样式(例如,在新行上),您可以使用 TextSpan。从 Flutter 文档借用的示例带有 ' ' 插入新行来说明:
return Container(
child: RichText(
text: TextSpan(
text: 'Hello \n ',
style: DefaultTextStyle.of(context).style,
children: const <TextSpan>[
TextSpan(
text: 'bold',
style: TextStyle(fontWeight: FontWeight.bold)),
TextSpan(text: ' world!'),
],
),
));