Skip to main content

prefer-text-rich

added in: 1.8.0
🛠

Warns when a RichText widget is used instead of Text.rich.

RichText does not handle text scaling very well, so if accessability is important for you, use Text.rich instead.

Example

❌ Bad:

// LINT
RichText(
text: TextSpan(
text: 'Hello ',
children: [
TextSpan(text: 'bold'),
TextSpan(text: ' world!'),
],
),
);

✅ Good:

Text.rich(
TextSpan(
text: 'Hello ',
children: [
TextSpan(text: 'bold'),
TextSpan(text: ' world!'),
],
),
)