flutter - 如何在 Flutter 中装饰文字笔划?
问题描述
如何在 Flutter 中装饰文字笔划?就像-webkit-text-stroke - CSS
解决方案
自从在 TextStyle 中添加了前景色后,无需任何变通方法就可以实现描边。在 TextStyle 文档中添加了填充边框文本下的描边的显式示例:https ://master-api.flutter.dev/flutter/painting/TextStyle-class.html#painting.TextStyle.6
此示例在此处复制:
Stack(
children: <Widget>[
// 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],
),
),
],
)
通过删除 Stack 并仅使用第一个笔画 Text 小部件,可以单独进行笔画。笔画/填充顺序也可以通过交换第一个和第二个文本小部件来调整。
推荐阅读
- reactjs - JSON输入错误的意外结束
- python - 将属性 pandas.DataFrame.shape 应用于存储在元组中的多个数据框
- vba - 删除值为零的数据标签然后重置 - VBA
- c# - 循环 HttpRequests 后如何重新排序项目
- mysql - MySQL 创建可以声明和设置选择结果的存储函数
- java - 如何停止工作 ScheduledExecutorService?
- python - 定义名称时 Python3 中的名称错误
- powershell-3.0 - PowerShell 变量到 SMTP 电子邮件
- java - 在 Java/Python 中生成时间序列数据
- protractor - Cucumber 无法从数据表中分离出两个不同的字符串