flutter - 如何在 Flutter 中通过文本划线?

标签 flutter dart text

在 Flutter 中使用 TextStyle() 类,如何突破旧价格?

最佳答案

直接将删除线装饰应用于 Text 小部件:

Text('\$8.99', style: TextStyle(decoration: TextDecoration.lineThrough))

您还可以使用 RichText 设置段落的单独跨度样式。小部件,或 Text.rich()构造函数。

基于 this example code , 以显示折扣价:

RichText()

new RichText(
  text: new TextSpan(
    text: 'This item costs ',
    children: <TextSpan>[
      new TextSpan(
        text: '\$8.99',
        style: new TextStyle(
          color: Colors.grey,
          decoration: TextDecoration.lineThrough,
        ),
      ),
      new TextSpan(
        text: ' \$3.99',
      ),
    ],
  ),
)

Text.rich()

Text.rich(TextSpan(
    text: 'This item costs ',
    children: <TextSpan>[
      new TextSpan(
        text: '\$8.99',
        style: new TextStyle(
          color: Colors.grey,
          decoration: TextDecoration.lineThrough,
        ),
      ),
      new TextSpan(
        text: ' \$3.99',
      ),
    ],
 ),
)

关于flutter - 如何在 Flutter 中通过文本划线?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50722987/

相关文章:

Flutter:如何将数学方程包装在容器中?

android - 如何在Flutter上禁用或处理最小化应用程序功能

C++ 快速将 int 数组内容转储到文本文件中

flutter - CERTIFICATE_VERIFY_FAILED flutter

function - dart 是否支持运算符重载

java - 如何在 Matlab 中测量渲染的文本?

html - <button> 中的文本未显示或移出按钮

flutter - 如何在访问新数据之前清除 FutureBuilder 中的 snapshot.data

events - Flutter:如何防止按键时的默认行为?

flutter - Dart/flutter 日期格式