我正在尝试弄清楚如何在多行上显示我的文本。这是我的代码:
title: Row(
children: [
Text(
_snapshot.data['username'],
style: TextStyle(
color: Colors.black,
fontSize: 20,
fontWeight: FontWeight.w700),
),
SizedBox(width: 5.0),
Text(
"${comment.data()['comment']}",
style: TextStyle(
color: Colors.black,
fontSize: 20,
fontWeight: FontWeight.w500),
)
],
),
但是当文本太长时我会得到这个错误:
当我用扩展包住第二个文本时,它看起来像那样
我想要这样的东西
最佳答案
我想你可以尝试使用 RichText,看这段代码:
RichText(
text: TextSpan(
text: 'Title ', // _snapshot.data['username']
style: TextStyle(fontWeight: FontWeight.bold, color: Colors.black),
children: <TextSpan>[
TextSpan(//"${comment.data()['comment']}"
text: 'this is a very long text text text'
'text text text text text text text text text text'
'text text text text text text text text text',
style: TextStyle(
fontWeight: FontWeight.normal,
),
)
],
),
),
关于firebase - 如何在多行上显示我的文本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67426534/