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.
Asked
Active
Viewed 662 times
0

WSBT
- 33,033
- 18
- 128
- 133

Saurabh Belwal
- 21
- 3
-
Does this answer your question? [Display a few words in different colors in Flutter](https://stackoverflow.com/questions/50551933/display-a-few-words-in-different-colors-in-flutter) – Iván Yoed Mar 09 '22 at 17:00
4 Answers
2
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_')

griffins
- 7,079
- 4
- 29
- 54
0
Row(
children: [
Text(
'H',
style: TextStyle(color: Colors.orange),
),
Text('ello')
],
),

M Karimi
- 1,991
- 1
- 17
- 34
0
Row(
children: [
Text(
'H',
style: TextStyle(color: Colors.orange),
),
Text('ELLO',style: TextStyle(color: Colors.black),],
),
0
RichText( text: TextSpan( text: 'H', style: TextStyle(color:Colors.orange), children: const [ TextSpan(text: 'ello', style: TextStyle()), ], ), )
you can use https://api.flutter.dev/flutter/widgets/RichText-class.html

Genius_balu
- 162
- 5