prefer_text_rich

SeverityQuick FixOptions
Info

Details

PREFER using Text.rich instead of RichText.

Using Text.rich is more efficient than RichText because of possible const constructor usage.

Bad
RichText(
  text: const TextSpan(
    text: 'Pyramid',
    children: [
      TextSpan(text: 'Lint'),
    ],
  ),
)
Good
const Text.rich(
  TextSpan(
    text: 'Pyramid',
    children: [
      TextSpan(text: 'Lint'),
    ],
  ),
)

Usage

To enable the prefer_text_rich rule, add prefer_text_rich under custom_lint > rules in your analysis_options.yaml file:

custom_lint:
  rules:
    - prefer_text_rich