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?
Step 1: Locate the file where you have placed the Text widget. Step 2: Inside the Text widget, add the Style parameter and assign the TextStyle widget. Step 3: Inside the TextStyle widget, add the color parameter and set the color of your choice. For example, color: Colors.
Steps to change theme text color in Flutter You can change theme text color in Flutter, by defining the TextTheme (inside MaterialApp) and then adding headings type. For example, headline1 , headline2 , BodyText1 , and so on. After that, you can assign the TextStyle widget with the color of your choice.
Flutter – Text Widget – Bold To display bold text in Text widget in Flutter, set font weight to bold in style property for the Text widget.
To change TextField underline color in Flutter, add styling to the TextField widget. Basically, you provide the styling instructions by using the InputDecoration widget with the required parameters.
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)),
],
),
);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With