我在 TextStyle 中搜索了阴影选项,但没有找到。所以我问:如何在 flutter 中为文本添加阴影?可能吗? 示例:
new Text(
"asd"
style: new TextStyle(
//add shadow?
));
最佳答案
文本阴影现在是 TextStyle
的属性截至this commit
要启用文本阴影,请确保您使用的是最新版本的 Flutter ( $ flutter upgrade
) 并提供 List<Shadow>
至TextStyle.shadows
:
import 'dart:ui';
...
Text(
'Hello, world!',
style: TextStyle(
shadows: <Shadow>[
Shadow(
offset: Offset(10.0, 10.0),
blurRadius: 3.0,
color: Color.fromARGB(255, 0, 0, 0),
),
Shadow(
offset: Offset(10.0, 10.0),
blurRadius: 8.0,
color: Color.fromARGB(125, 0, 0, 255),
),
],
),
),
...
请记住,阴影将按照提供的顺序绘制。
https://stackoverflow.com/questions/44303882/