热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

如何在Flutter中装饰文字笔划?

如何解决《如何在Flutter中装饰文字笔划?》经验,为你挑选了2个好方法。

如何在Flutter中装饰文字笔划?这就像-webkit-text-stroke-CSS



1> PieterAelse..:

我也在寻找这个,但是找不到它.但我确实在TextStyle中找到了使用4个阴影的解决方法:

Text("Border test",
    style: TextStyle(
      inherit: true,
      fontSize: 48.0,
      color: Colors.pink,
      shadows: [
        Shadow( // bottomLeft
          offset: Offset(-1.5, -1.5),
          color: Colors.white
        ),
        Shadow( // bottomRight
          offset: Offset(1.5, -1.5),
          color: Colors.white
        ),
        Shadow( // topRight
          offset: Offset(1.5, 1.5),
          color: Colors.white
        ),
        Shadow( // topLeft
          offset: Offset(-1.5, 1.5),
          color: Colors.white
        ),
      ]
    ),
);

我还在GitHub上打开了一个问题:https://github.com/flutter/flutter/issues/24108



2> Gary Qian..:

由于在TextStyle中添加了前景色,因此无需任何变通方法即可进行中风。TextStyle文档中添加了填充边框文本下方的笔触的显式示例:https : //master-api.flutter.dev/flutter/painting/TextStyle-class.html#painting.TextStyle.6

此示例在此处转载:

Stack(
  children: [
    // Stroked text as border.
    Text(
      'Greetings, planet!',
      style: TextStyle(
        fontSize: 40,
        foreground: Paint()
          ..style = PaintingStyle.stroke
          ..strokeWidth = 6
          ..color = Colors.blue[700],
      ),
    ),
    // Solid text as fill.
    Text(
      'Greetings, planet!',
      style: TextStyle(
        fontSize: 40,
        color: Colors.grey[300],
      ),
    ),
  ],
)

可以通过删除堆栈并仅使用第一个笔触文本小部件来单独进行笔划。笔划/填充顺序也可以通过交换第一个和第二个“文本”小部件来调整。


推荐阅读
author-avatar
_忘却的思念_
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有