如何在 Flutter 中将颜色作为 UI 文本的一部分? [英] How to make color part of a text for UI in Flutter?
本文介绍了如何在 Flutter 中将颜色作为 UI 文本的一部分?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
How can I change the color of part of a text?
I'm trying to make it so the text says "Don't have an account? Register now!
" but I want to add color to the Register now!
part. How can I do this if possible?
解决方案
Use 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)),
],
),
);
这篇关于如何在 Flutter 中将颜色作为 UI 文本的一部分?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文