Skip to content
pubscout

flutter_decorated_text

2.2.0, released 7 months ago by gabdsg.com

A widget to style and interact with parts of a text string based on predefined rules.

WASM-ready
$ flutter pub add flutter_decorated_text
Source repository

What it does

The DecoratedText widget allows you to style and make parts of a text string interactive using predefined rules like words, prefixes, tags, URLs, or custom regular expressions. It supports callbacks for taps on matched text and allows text selection.

AI-written summary of version 2.2.0, based on the package's README and metadata. Report an inaccuracy

Use it when

  • You need to highlight specific words, hashtags, mentions, or links inside a block of text.
  • You want users to be able to tap on specific styled portions of text such as URLs or hashtags.
  • You need custom regular expression styling and inline widget builders within text.

Skip it when

  • You only need standard rich text formatting without pattern matching or interactive spans.
  • You are building a full markdown parser or rich text editor requiring complex syntax trees.

Strengths

  • Comes with many built-in rules for words, prefixes, tags, and URLs.
  • Supports interactive tap callbacks and selectable text.
  • Optimized with internal RegExp caching and efficient tag deduplication.

Weaknesses

  • Limited to rule-based pattern matching and styling rather than full markup parsing.
  • Complex custom regexes may require manual caching for optimal performance.

Setup

Kind
Flutter widgets
Effort
Low
Code generation
No
Direct dependencies
1
DecoratedText(
    text: "Like twitter accounts @gabdsg or hashtags #decoratedtext",
    rules: [
        DecoratorRule.startsWith(
            text: "@",
            onTap: (match) {
                print(match);
            },
            style: TextStyle(
                color: Colors.blue,
            ),
        ),
    ],
)

Alternatives

Packages that do the same job and could replace flutter_decorated_text.

  • re_editor

    A lightweight text and code editor widget for Flutter with syntax highlighting and folding.

  • ticketcher

    Create ticket-style cards, boarding passes, and coupons with custom notches, borders, and dividers.

  • highlight_text

    A Flutter widget to highlight specific words in text with custom styles and actions.

  • stroke_text

    A simple Flutter widget to apply a stroke or border style to text.