ExpandableText class
A stateful widget that displays expandable/collapsible text content with a title.
The ExpandableText
widget is useful for displaying long pieces of text in a condensed form.
It allows the user to expand or collapse the content by tapping on the title or an icon,
making it ideal for showing additional details on demand.
This widget also provides an option to copy the content to the clipboard, accessible through a copy icon button. If the content is null or empty, a placeholder message is shown instead.
Example usage:
ExpandableText(
title: 'Description',
content: 'This is a long description that can be expanded or collapsed.',
);
Parameters:
title
(String): The title of the expandable section, shown as a clickable text.content
(String?): The text content to display when expanded. Defaults to 'No Data to show' if null or empty.collapsedLines
(int): The number of lines to show when the content is collapsed. Default is 2.
This widget uses an InkWell
widget to toggle the expansion state and shows an icon that indicates
whether the text is currently expanded or collapsed. The copy icon button allows copying the content.
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatefulWidget
- ExpandableText
Constructors
- ExpandableText({Key? key, required String title, required String? content, int collapsedLines = 2})
-
const
Properties
- collapsedLines → int
-
final
- content → String?
-
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- title → String
-
final
Methods
-
createElement(
) → StatefulElement -
Creates a StatefulElement to manage this widget's location in the tree.
inherited
-
createState(
) → State< StatefulWidget> -
Creates the mutable state for this widget at a given location in the tree.
override
-
debugDescribeChildren(
) → List< DiagnosticsNode> -
Returns a list of DiagnosticsNode objects describing this node's
children.
inherited
-
debugFillProperties(
DiagnosticPropertiesBuilder properties) → void -
Add additional properties associated with the node.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toDiagnosticsNode(
{String? name, DiagnosticsTreeStyle? style}) → DiagnosticsNode -
Returns a debug representation of the object that is used by debugging
tools and by DiagnosticsNode.toStringDeep.
inherited
-
toString(
{DiagnosticLevel minLevel = DiagnosticLevel.info}) → String -
A string representation of this object.
inherited
-
toStringDeep(
{String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) → String -
Returns a string representation of this node and its descendants.
inherited
-
toStringShallow(
{String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) → String -
Returns a one-line detailed description of the object.
inherited
-
toStringShort(
) → String -
A short, textual description of this widget.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited