RichText can be displayed in multiple styles, such as bold, italic, and color, using the RichText Flutter widget. It lets you create complex text layouts with different fonts, colors, and sizes in a single block of text. With the help of the Flutter widget RichText, you may display text in a text block in multiple styles. Different text parts can have more stylistic control with RichText than with the standard Text widget, which uses a single style for the entire Text.
Key Features
- Multiple styles: Apply different styles to parts of the text.
- Text spans: To define stylized text parts, use TextSpan widgets.
- Flexible layout: Accommodates intricate text layouts with various fonts, colors, and sizes.
Example
RichText(
text: TextSpan(
children: [
TextSpan(
text: 'Coder, ',
style: TextStyle(fontSize: 20, color: Colors.grey),
),
TextSpan(
text: 'ICU!',
style: TextStyle(fontSize: 20, color: Colors.green, fontWeight: FontWeight.bold),
),
],
),
)