问题描述
对于文本小部件,我们可能会使用 strike
或 underline
的文本修饰
style: TextStyle(decoration: Textdecoration.lineThrough),style: TextStyle(decoration: Textdecoration.underline),
有没有什么办法可以在文字修饰中同时获得?或者是否有任何解决方案与 Boxdecoration 有关?我试过了,但没有成功。
解决方法
使用 combine instade
Text(
"Hello world!",style: TextStyle(
decoration: TextDecoration.combine(
[TextDecoration.underline,TextDecoration.lineThrough]),),)
,
一种可能的解决方案是像这样使用 Container
:
Container(
child: Text(
'This text has underline as well as linethrough',style: TextStyle(decoration: TextDecoration.lineThrough),decoration: BoxDecoration(
border: Border(
bottom: BorderSide(
color: const Color(0xFF000000),
输出:
,您需要添加
装饰
在用于执行此操作的文本小部件中: 这是示例:
decoration: TextDecoration.combine(
[TextDecoration.underline,