Expandable Tile
The ExpandableTextTile
widget displays a tile that can expand and collapse to show or hide additional text. It includes a title, an optional icon, and a toggle to show more or less text.
Display
Features
- Expandable and Collapsible Text: The widget allows users to expand and collapse the text by clicking “show more” or “show less”. It is styled with a blue color to indicate that it is clickable.
- Customizable Icon: An optional icon can be displayed next to the text.
- Automatic Text Overflow Handling: The widget automatically handles text overflow and displays an ellipsis if the text exceeds the maximum lines when collapsed. This is achieved using
StatefulBuilder
- Tile Padding: The tile padding is set to
EdgeInsets.only(left: 0, right: 15)
by default. - Control Affinity: The control affinity is set to
ListTileControlAffinity.trailing
by default. - Initial Expansion State: The tile is initially collapsed (
initiallyExpanded: false
).
Usage
Import ExpandableTextTile
in any page to display a tile with expandable text. It takes the following parameters:
title
: A string representing the title of the tile.text
: A string representing the text to display within the tile.icon
: (Optional) AnIconData
to display an icon next to the text. The default icon isIcons.info_outline
.