Using the TextStyle()
class in Flutter, how can I strike through an old price?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
You can style separate spans of a paragraph by using the RichText
widget.
Based on this example code, to show a discounted price:
new RichText(
text: new TextSpan(
text: 'This item costs ',
children: <TextSpan>[
new TextSpan(
text: '$8.99',
style: new TextStyle(
color: Colors.gray,
decoration: TextDecoration.lineThrough,
),
),
new TextSpan(
text: ' $3.99',
),
],
),
)
回答2:
style: TextStyle(decoration: TextDecoration.lineThrough),