Expansible class

A StatefulWidget that expands and collapses.

An Expansible consists of a header, which is always shown, and a body, which is hidden in its collapsed state and shown in its expanded state.

The Expansible is expanded or collapsed with an animation driven by an AnimationController. When the widget is expanded, the height of its body animates from 0 to its fully expanded height.

This widget is typically used with ListView to create an "expand / collapse" list entry. When used with scrolling widgets like ListView, a unique PageStorageKey must be specified as the key, to enable the Expansible to save and restore its expanded state when it is scrolled in and out of view.

Provide headerBuilder and bodyBuilder callbacks to build the header and body widgets. An additional expansibleBuilder callback can be provided to further customize the layout of the widget.

The Expansible does not inherently toggle the expansion state. To toggle the expansion state, call ExpansibleController.expand and ExpansibleController.collapse as needed, most typically when the header returned in headerBuilder is tapped.

See also:

  • ExpansionTile, a Material-styled widget that expands and collapses.
Inheritance

Constructors

Expansible({Key? key, required ExpansibleComponentBuilder headerBuilder, required ExpansibleComponentBuilder bodyBuilder, required ExpansibleController controller, ExpansibleBuilder expansibleBuilder = _defaultExpansibleBuilder, Duration duration = const Duration(milliseconds: 200), Curve curve = Curves.ease, Curve? reverseCurve, bool maintainState = true})
Creates an instance of Expansible.
const

Properties

bodyBuilder ExpansibleComponentBuilder
Builds the collapsible body.
final
controller ExpansibleController
Expands and collapses the widget.
final
curve Curve
The curve of the expansion animation.
final
duration Duration
The duration of the expansion animation.
final
expansibleBuilder ExpansibleBuilder
Builds the widget with the results of headerBuilder and bodyBuilder.
final
hashCode int
The hash code for this object.
no setterinherited
headerBuilder ExpansibleComponentBuilder
Builds the always-displayed header.
final
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
maintainState bool
Whether the state of the body is maintained when the widget expands or collapses.
final
reverseCurve Curve?
The reverse curve of the expansion animation.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

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