Skip to content
pubscout

expandable_text

2.3.0, released 5 years ago by an unverified publisher

Flutter widget that shows truncated text with an expand/collapse link.

WASM-ready
$ flutter pub add expandable_text
Source repository

What it does

Provides an ExpandableText widget that initially shows a defined number of lines of text. Appends a configurable link to expand the full text or collapse it again, with support for tappable hashtags, mentions, and URLs.

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

Use it when

  • You need to truncate long text blocks like user comments or posts with a show more link.
  • You require interactive elements inside the text such as hashtags, mentions, and URLs.

Skip it when

  • You need complex rich text formatting beyond simple styles, URLs, hashtags, and mentions.

Strengths

  • Supports expansion and collapse animations
  • Built-in handling for URLs, @mentions, and #hashtags
  • Optional prefix text and tap callbacks

Weaknesses

  • Limited to specific built-in interactive tokens like URLs, mentions, and hashtags

Setup

Kind
Flutter widgets
Effort
Low
Code generation
No
Direct dependencies
0
ExpandableText(
  longText,
  expandText: 'show more',
  collapseText: 'show less',
  maxLines: 1,
  linkColor: Colors.blue,
)

Alternatives

Packages that do the same job and could replace expandable_text.

  • auto_size_text

    Pick auto_size_text if you need text to automatically resize to fit a specific boundary instead of truncating and expanding.