我想更改文本中字母的顏色,例如。我想將H文本 Hello 中的字母顏色更改為橙??色,并讓它保持ello原樣。那么如何改變它。
uj5u.com熱心網友回復:
如果它是靜態的,您可以使用RichText
例子
RichText(
text: TextSpan(
text: 'H',
style: TextStyle(color:Colors.orange),
children: const <TextSpan>[
TextSpan(text: 'ello', style: TextStyle()),
],
),
)
如果它是動態的,您可能想要使用插件,例如simple_rich_text
SimpleRichText(r'*_/this is all three*_/ (*{color:red}bold*, _{color:green}underlined_, and /{color:brown}italicized/). _{push:home;color:blue}clickable hyperlink to home screen_')
uj5u.com熱心網友回復:
Row(
children: [
Text(
'H',
style: TextStyle(color: Colors.orange),
),
Text('ello')
],
),
uj5u.com熱心網友回復:
Row(
children: [
Text(
'H',
style: TextStyle(color: Colors.orange),
),
Text('ELLO',style: TextStyle(color: Colors.black),],
),
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/433749.html
