Flutter “空芯”文字

2022-11-09  本文已影响0人  倪大头
image.png

给TextStyle里的foreground属性传一个Paint即可:

Text(
  'Hello Datou', 
  style: TextStyle(
    fontSize: 45.sp,
    fontWeight: FontWeight.w700,
    foreground: Paint()
       ..style = PaintingStyle.stroke
       ..strokeWidth = 1
       ..color = Colors.white,
  ),
)

foreground属性与color互斥,文字颜色要在Paint()中设置
Paint().style要设为PaintingStyle.stroke才有空芯效果
strokeWidth为线条宽度

上一篇 下一篇

猜你喜欢

热点阅读