【问题标题】:Obtain a text with underline and strikethrough at the same time同时获取带下划线和删除线的文本
【发布时间】:2021-05-12 16:54:19
【问题描述】:

对于文本小部件,我们可以使用strikeunderline 的文本装饰

style: TextStyle(decoration: TextDecoration.lineThrough),
style: TextStyle(decoration: TextDecoration.underline),

有没有什么方法可以在文字装饰中同时获得?或者 Boxdecoration 有什么解决方案吗?我试过了,但没有成功。

【问题讨论】:

    标签: flutter flutter-text


    【解决方案1】:

    使用组合替换

    Text(
      "Hello world!",
      style: TextStyle(
        decoration: TextDecoration.combine(
            [TextDecoration.underline, TextDecoration.lineThrough]),
      ),
    )
    

    【讨论】:

      【解决方案2】:

      你需要添加

      装饰

      在您的文本小部件中执行此操作: 这是示例:

      decoration: TextDecoration.combine(
          [TextDecoration.underline, TextDecoration.lineThrough]),
      

      【讨论】:

        【解决方案3】:

        一种可能的解决方案是像这样使用Container

               Container(
                  child: Text(
                    'This text has underline as well as linethrough',
                    style: TextStyle(decoration: TextDecoration.lineThrough),
                  ),
                  decoration: BoxDecoration(
                    border: Border(
                      bottom: BorderSide(
                        color: const Color(0xFF000000),
                      ),
                    ),
                  ),
                ),
                     
        

        输出:

        【讨论】:

          猜你喜欢
          • 2013-03-12
          • 2011-03-01
          • 1970-01-01
          • 1970-01-01
          • 2019-03-01
          • 1970-01-01
          • 2013-12-30
          • 2021-01-22
          • 2018-02-06
          相关资源
          最近更新 更多