How do I change the color of a subtext value in flutter. I have the following code and would like "sign in" and "sign up" to be in a different color
Thanks for your help
child: Text(
(isSignInScreenState)
? "don't have an account? sign up"
: "already have an account? sign in",
style: TextStyle(
fontSize: 18.0,
),
),
Use RichText
and 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)),
],
),
),
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments