Home > Software engineering >  How to change colors of text letters in flutter
How to change colors of text letters in flutter

Time:02-27

I want to change the color of letters in a text eg. I want to change the color of letter H' to orange from text Hello and let the ello' as it is in flutter. So how to change it.

CodePudding user response:

If its static you can use RichText

example

RichText(
  text: TextSpan(
    text: 'H',
    style: TextStyle(color:Colors.orange),
    children: const <TextSpan>[
      TextSpan(text: 'ello', style: TextStyle()),
     
    ],
  ),
)

If its dynamic you might want to use plugins eg simple_rich_text

SimpleRichText(r'*_/this is all three*_/ (*{color:red}bold*, _{color:green}underlined_, and /{color:brown}italicized/). _{push:home;color:blue}clickable hyperlink to home screen_')

CodePudding user response:

Row(
          children: [
            Text(
              'H',
              style: TextStyle(color: Colors.orange),
            ),
            Text('ello')
          ],
        ),

CodePudding user response:

Row(
   children: [
   Text(
   'H',
    style: TextStyle(color: Colors.orange),
   ),
   Text('ELLO',style: TextStyle(color: Colors.black),],
        ),
  • Related