【发布时间】:2021-04-03 15:36:52
【问题描述】:
我试图突出显示动态来自 JSON 的字符串中的任何数字和特殊字符,例如“%”。 这是我当前的实现,但我不明白如何动态更改它。
RichText(
overflow: TextOverflow.ellipsis,
textAlign: TextAlign.center,
maxLines: 4,
text: TextSpan(
children: <TextSpan>[
TextSpan(
text: 'Hey I\'m',
style: TextStyle(
color: kDarkBlue, fontSize: 21)),
TextSpan(
text: '1234 ',
style: TextStyle(
fontWeight: FontWeight.w800,
fontSize: 24)),
TextSpan(
text: 'and',
style: TextStyle(fontSize: 21)),
TextSpan(
text: '%',
style: TextStyle(
fontWeight: FontWeight.w800,
fontSize: 24)),
],
),
),
【问题讨论】:
-
您是否尝试过在这种情况下使用正则表达式?
标签: flutter user-interface dart flutter-layout flutter-design