Build pub package license

This Flutter package includes the widget ExpandableText which you can use to initially only show a defined number of lines of a probably long text. The widget appends a configurable text link which let's the user expand the full text, or collapse it again.

Example with maxLines=1

Getting started

Add this to your package's pubspec.yaml file:

  expandable_text: 2.1.0+1

Next, import the package into your dart code:

import 'package:expandable_text/expandable_text.dart';


Example which shows an expandable text if longText exceeds one line:

Widget build(BuildContext context) {
    return ExpandableText(
        expandText: 'show more',
        collapseText: 'show less',
        maxLines: 1,


  • Link to expand the collapsed text (expandText)
  • Expand and collapse animation (animation, animationDuration, animationCurve)
  • Optional link to collapse the expanded text (collapseText)
  • Configure the style of the link (linkStyle / linkColor)
  • Control whether the ellipsis is part of the link (linkEllipsis)
  • Optional prefix text with style and tap callback (prefixText, prefixStyle, onPrefixTap)
  • Configure the number of visible lines of the collapsed text (maxLines)
  • Control the default expanded state (expanded)
  • Callback for expanded changed event (onExpandedChanged)
  • Tap on the text to expand or collapse the text (expandOnTextTap, collapseOnTextTap)

Bugs and feature requests

Have a bug or a feature request? Please first search for existing and closed issues. If your problem or idea is not addressed yet, please open a new issue.

Code copyright 2020–2021 Florian Weinaug. Code released under the MIT license.