How can I make a line through text in Flutter?

2019-02-14 05:56发布

问题:

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),


标签: dart flutter