I am writing an application which shows a few words in different colors in flutter.
I tried to load HTML files using the plugin flutter_html_view but that one doesn't support styles(inline). I also tried to use markdown.
How can I achieve this?
Steps. 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.
1. The computeLuminance() method from the Color class. You can use this method to programmatically compute the background luminance then determine whether the text color should be white or black, like this: Text( 'Hello', style: TextStyle( fontSize: 80, color: _backgroundColor.
One possible approach is to use a Stack. Set the background color to your grey (i think, color blind), add the white piece as an image positioned at the bottom. Lastly add your button, again positioned at the bottom.
Use RichText class
var text = new RichText( text: new TextSpan( // Note: Styles for TextSpans must be explicitly defined. // Child text spans will inherit styles from parent style: new TextStyle( fontSize: 14.0, color: Colors.black, ), children: <TextSpan>[ new TextSpan(text: 'Hello'), new TextSpan(text: 'World', style: new TextStyle(fontWeight: FontWeight.bold)), ], ), );
You can achieve this by using a RichText class class with TextStyle class
RichText
widget helps to answer and achieve the above cases
RichText( textAlign: TextAlign.center, text: TextSpan(children: <TextSpan>[ TextSpan( text: "I agree to the ", style: TextStyle(color: Colors.black87)), TextSpan( text: "Terms and Conditions", style: TextStyle( color: Colors.deepPurple, fontWeight: FontWeight.bold)), ]), )
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