【问题标题】:Draw horizontal stroke on text flutter在文本颤动上绘制水平描边
【发布时间】:2020-10-27 06:54:58
【问题描述】:

是否可以在Text 周围绘制水平笔划,像我在下面展示的那样颤动?

sample image

【问题讨论】:

    标签: flutter dart


    【解决方案1】:

    您可以使用 Stack 小部件来做到这一点。

            Stack(
              children: <Widget>[
                Text(
                  'N',
                ),
                Positioned(
                  top: 8,
                  child: Container(
                  width: 10,
                  height: 2,
                  color: Colors.grey
                ),
               ),
                Positioned(
                  top: 12,
                  child: Container(
                  width: 10,
                  height: 2,
                  color: Colors.grey
                ),
               ),
              ],
            ),
    

    您可以将 Stack 小部件放入一些容器中以限制小部件的大小。

    【讨论】:

      【解决方案2】:

      您可以在文本小部件中使用 in 样式在文本中绘制单行

         Text('N',style: TextStyle(fontSize:30,decoration: TextDecoration.lineThrough,
                      decorationThickness: 2.85,),)
      

      如果你想双击,但你可以创建一个线条图像然后将其显示到一个文本小部件中,你可以检查以下链接,或者你可以使用 savke 的以下答案

      custom-strikethrough-to-text

      【讨论】:

        猜你喜欢
        • 2022-01-16
        • 1970-01-01
        • 2021-10-27
        • 1970-01-01
        • 1970-01-01
        • 2019-11-19
        • 2019-08-05
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多