如何制作轮廓文本



如何为text小部件制作轮廓文本?这就像中风效应

您可以尝试此选项:https://stackoverflow.com/a/53211151/1534666


答案副本:我也在找这个,但没能找到。但我确实找到了一个变通方法,在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

UPD:

我不认为这是最好的解决方案,但它可以

Stack(
children: <Widget>[
Text(
'TEXT',
textAlign: TextAlign.center,
style: TextStyle(
color: Colors.purple,
fontWeight: FontWeight.bold,
fontSize: 36.0),
),Text(
'TEXT',
textAlign: TextAlign.center,
style: TextStyle(
foreground: Paint()..color = Colors.white..style = PaintingStyle.stroke..strokeWidth = 1.0,
fontWeight: FontWeight.bold,
fontSize: 36.0),
),
],
);

TextStyle中,不能同时定义colorforeground,所以我尝试将Stack与两个具有不同装饰的相同Text一起使用。

正如我所说,这不是最好的解决方案,但也许它适合

样式:GoogleFonts.londrinaOutline((,

这很简单,但并不完美。。。。!

使用bordered_text包

BorderedText(
strokeColor: Colors.white,
strokeWidth: 6,
child: Text(
'Bordered Text',
style: const TextStyle(
fontSize: 130,
fontWeight: FontWeight.bold,
color: blackColor
),
),
),

最新更新