如何更改文本部分的颜色?我正在尝试使它显示为“ Don't have an account? Register now!
”,但我想为Register now!
部分添加颜色。如果可能的话我该怎么办?
使用RichText
https://docs.flutter.io/flutter/widgets/RichText-class.html
RichText(
text: TextSpan(
text: "Don't have an account? ",
style: TextStyle(color: Colors.black, fontSize: 40),
children: <TextSpan>[
TextSpan(text: ' Register now!', style: TextStyle(color: Colors.red)),
],
),
);