如何在flutter中更改潜文值的颜色。我有以下代码,并希望“登录”和“注册”是在不同的颜色
谢谢你的帮忙
child: Text(
(isSignInScreenState)
? "don't have an account? sign up"
: "already have an account? sign in",
style: TextStyle(
fontSize: 18.0,
),
),发布于 2019-09-21 07:21:20
使用RichText和TextSpan
String question = isSignInScreenState ? "don't have an account? " : "already have an account? ";
String signText = isSignInScreenState ? "sign up" : "sign in";
// ...
RichText(
text: TextSpan(
text: question,
style: TextStyle(fontSize: 18.0, color: Colors.black),
children: <TextSpan>[
TextSpan(text: signText, style: TextStyle(fontSize: 18.0, color: Colors.red)),
],
),
),https://stackoverflow.com/questions/58036004
复制相似问题