答案 0 :(得分:1)
在完美再现示例图片的下方使用TextSpan
小部件
RichText(
text: TextSpan(
// set the default style for the children TextSpans
style: Theme.of(context).textTheme.body1.copyWith(fontSize: 30),
children: [
TextSpan(
text: 'Hello, ',
),
TextSpan(
text: 'Wor',
style: TextStyle(
color: Colors.blue
)
),
TextSpan(
text: 'ld',
),
]
)
)
答案 1 :(得分:0)
在TextField中,这已经变得很困难,因为您不知道用户输入了什么。 如果您正在谈论“文本”字段,则可以使用RichText
RichText(
text: TextSpan(
// set the default style for the children TextSpans
style: Theme.of(context).textTheme.body1.copyWith(fontSize: 30),
children: [
TextSpan(
text: 'Styling ',
),
TextSpan(
text: 'text',
style: TextStyle(
color: Colors.blue
)
),
TextSpan(
text: ' in Flutter',
),
]
)
)
答案 2 :(得分:0)
我认为您正在寻找的是富文本编辑器或文本字段,我认为flutter不支持开箱即用。我发现最好的一些酒吧是zypher或creamy_field 在预发行版上重新编写了zypher,可能需要注意这一点