Published on

How to use multiple text styles in Flutter

Authors
  • avatar
    Name
    Saad Bash

User Flutter's built-in RichText widget to display text with multiple different styles.

RichText(
  text: TextSpan(
    text: 'Hello ',
    style: DefaultTextStyle.of(context).style,
    children: const <TextSpan>[
      TextSpan(text: 'Blue & Bold', style: TextStyle(fontWeight: FontWeight.bold, color: Colors.red)),
      TextSpan(text: ' world!'),
    ],
  ),
)

Output:

Red & Bold text example

More info: RichText Class