Last updated 3 years ago by Darshan Kawar
flutterAs the name suggests, RichText
provides more options to the way a text
is displayed on the screen.
The style
property of text
widget is used to apply various styles to a text, but a limitation of it is, the style gets applied to the entire text irrespective of whether the text is a single line or multiline. Consider below snippet to render a single line of text on screen:
Container(
padding: EdgeInsets.all(10),
child: Center(
child: Text(
**'The future belongs to those who prepare for it today.'**)
)
)
With above code, if we apply fontSize
as 20, fontStyle
as italic
, the style will be applied to entire text, as below.
But, what if, we only want to underline a word from above text or show certain words of text as bold/italic or in different color and rest of the text as normal text?
RichText
widget helps to answer and achieve the above cases.