ExpansionTileController typedef
- @Deprecated('Use ExpansibleController instead. ' 'This feature was deprecated after v3.31.0-0.1.pre.')
Enables control over a single ExpansionTile's expanded/collapsed state.
It can be useful to expand or collapse an ExpansionTile programmatically, for example to reconfigure an existing expansion tile based on a system event. To do so, create an ExpansionTile with an ExpansionTileController that's owned by a stateful widget or look up the tile's automatically created ExpansionTileController with ExpansibleController.of.
build
method of a descendant of an ExpansionTile.
When the ExpansionTile is actually created in the same build
function as the callback that refers to the controller, then the
context
argument to the build
function can't be used to find
the ExpansionTileController (since it's "above" the widget
being returned in the widget tree). In cases like that you can
add a Builder widget, which provides a new scope with a
BuildContext that is "under" the ExpansionTile:
To create a local project with this code sample, run:
flutter create --sample=material.ExpansionTileController.1 mysample
A more efficient solution is to split your build function into
several widgets. This introduces a new context from which you
can obtain the ExpansionTileController. With this approach you
would have an outer widget that creates the ExpansionTile
populated by instances of your new inner widgets, and then in
these inner widgets you would use ExpansionTileController.of
.
The ExpansibleController.expand and ExpansibleController.collapse methods cause the ExpansionTile to rebuild, so they may not be called from a build method.
Remember to dispose of the ExpansionTileController when it is no longer needed. This will ensure we discard any resources used by the object.
Implementation
@Deprecated(
'Use ExpansibleController instead. '
'This feature was deprecated after v3.31.0-0.1.pre.',
)
typedef ExpansionTileController = ExpansibleController;