flutter-design

How to highlight only numbers and special characters inside Text in Flutter?

試著忘記壹切 提交于 2021-01-27 23:08:16
问题 I'm trying to highlight any numbers & special characters like '%' from a String that comes dynamically from JSON. This is my current implementation but I can't understand how to change it dynamically. 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)),