flutter - 有什么方法可以在 Flutter 中使 Text 和 Underline 不同的颜色?
解决方案
您可以在 Text 属性中使用 decorationColor: yourColor 来更改下划线的颜色。例如,如果您想为所有文本添加下划线:
Text("Your text",
style: TextStyle(
color: Colors.white
decoration: TextDecoration.underline,
decorationColor: Colors.yellow,
))
如果您只想在文本的一部分下划线,则必须将 RichText 与 TextSpan 一起使用。例如:
RichText(
text: TextSpan(
children: [
TextSpan(
text: "NOT UNDERLINED TEXT",
style: TextStyle(
color: Colors.white)
),
TextSpan(
text: "UNDERLINED TEXT",
style: TextStyle(
color: Colors.white
decoration: TextDecoration.underline,
decorationThickness: 2,
decorationStyle: TextDecorationStyle.wavy))
],
style: TextStyle(color: Colors.yellow)
))
推荐阅读
- javascript - 用户如何从 Spring Boot 应用程序的其余部分获取客户端?
- oracle - 管道函数oracle中的动态sql
- flutter - 使用cubit订阅,需要创建Timer(streamsubscription with cubit flutter)
- lisp - 自动将矩形转换为已知度数的凹弧
- docker - 无法连接到 Docker 上托管的 MLFlow 模型
- python - Python中使用月份缩写的正则表达式
- python - 如何使用 for 循环提取 loan_price 低于 500 的贷款?
- interface - 为什么不能在接口上使用带有表达式的 C# 9
- python - 通过 Discord.py 获得角色
- https - HTTPS 代理服务