【发布时间】:2019-07-04 20:48:48
【问题描述】:
如何为显示文本的不同部分应用不同的样式。如何在颤振中做到这一点?
例子:
你好世界
【问题讨论】:
如何为显示文本的不同部分应用不同的样式。如何在颤振中做到这一点?
例子:
你好世界
【问题讨论】:
这可以使用RichText来实现
RichText(
text: TextSpan(
text: 'Hello',
style: TextStyle(fontSize: 22, color: Colors.black),
children: <TextSpan>[
TextSpan(
text: 'World',
style: TextStyle(
fontSize: 24,
fontStyle: FontStyle.italic,
fontWeight: FontWeight.bold,
),
),
]
),
),
【讨论】:
return RichText(
text: TextSpan(
text: 'Can you ',
style: TextStyle(color: Colors.black),
children: <TextSpan>[
TextSpan(
text: 'find the',
style: TextStyle(
color: Colors.green,
decoration: TextDecoration.underline,
decorationStyle: TextDecorationStyle.wavy,
),
recognizer: _longPressRecognizer,
),
TextSpan(text: 'secret?'),
],
),
);
【讨论】: