Skip to main content

ExpansionTile

Struct ExpansionTile 

Source
pub struct ExpansionTile {
Show 34 fields pub key: Option<KeyRef>, pub leading: Option<WidgetRef>, pub title: WidgetRef, pub subtitle: Option<WidgetRef>, pub on_expansion_changed: Option<ValueChanged<bool>>, pub children: Vec<WidgetRef>, pub background_color: Option<Color>, pub collapsed_background_color: Option<Color>, pub trailing: Option<WidgetRef>, pub show_trailing_icon: bool, pub initially_expanded: bool, pub maintain_state: bool, pub tile_padding: Option<EdgeInsetsGeometry>, pub expanded_alignment: Option<AlignmentGeometry>, pub expanded_cross_axis_alignment: Option<CrossAxisAlignment>, pub children_padding: Option<EdgeInsetsGeometry>, pub icon_color: Option<Color>, pub collapsed_icon_color: Option<Color>, pub text_color: Option<Color>, pub collapsed_text_color: Option<Color>, pub shape: Option<ShapeBorderRef>, pub collapsed_shape: Option<ShapeBorderRef>, pub clip_behavior: Option<Clip>, pub control_affinity: Option<ListTileControlAffinity>, pub controller: Option<Ref<ExpansibleController>>, pub dense: Option<bool>, pub splash_color: Option<Color>, pub visual_density: Option<VisualDensity>, pub min_tile_height: Option<f64>, pub enable_feedback: Option<bool>, pub enabled: bool, pub expansion_animation_style: Option<AnimationStyle>, pub internal_add_semantic_for_on_tap: bool, pub states_controller: Option<Ref<WidgetStatesController>>,
}
Expand description

A single-line ListTile with an expansion arrow icon that expands or collapses the tile to reveal or hide the children.

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 ExpansionTile to save and restore its expanded state when it is scrolled in and out of view.

This class overrides the ListTileThemeData::icon_color and ListTileThemeData::text_color theme properties for its ListTile. These colors animate between values when the tile is expanded and collapsed: between icon_color, collapsed_icon_color and between text_color and collapsed_text_color.

The expansion arrow icon is shown on the right by default in left-to-right languages (i.e. the trailing edge). This can be changed using control_affinity. This maps to the leading and trailing properties of ExpansionTile.

§Accessibility

The accessibility behavior of ExpansionTile is platform adaptive, based on the device’s actual platform rather than the theme’s platform setting. This ensures that assistive technologies like VoiceOver on iOS and macOS receive the correct platform-specific semantics hints, even when the app’s theme is configured to mimic a different platform’s appearance.

See also:

Fields§

§key: Option<KeyRef>§leading: Option<WidgetRef>

A widget to display before the title.

Typically a CircleAvatar widget.

Depending on the value of control_affinity, the leading widget may replace the rotating expansion arrow icon.

§title: WidgetRef

The primary content of the list item.

Typically a Text widget.

§subtitle: Option<WidgetRef>

Additional content displayed below the title.

Typically a Text widget.

§on_expansion_changed: Option<ValueChanged<bool>>

Called when the tile expands or collapses.

When the tile starts expanding, this function is called with the value true. When the tile starts collapsing, this function is called with the value false.

Instead of providing this property, consider adding this callback as a listener to a provided controller.

§children: Vec<WidgetRef>

The widgets that are displayed when the tile expands.

Typically ListTile widgets.

§background_color: Option<Color>

The color to display behind the sublist when expanded.

If this property is None then ExpansionTileThemeData::background_color is used. If that is also None then Colors::TRANSPARENT is used.

See also:

§collapsed_background_color: Option<Color>

When not None, defines the background color of tile when the sublist is collapsed.

If this property is None then ExpansionTileThemeData::collapsed_background_color is used. If that is also None then Colors::TRANSPARENT is used.

See also:

§trailing: Option<WidgetRef>

A widget to display after the title.

Depending on the value of control_affinity, the trailing widget may replace the rotating expansion arrow icon.

§show_trailing_icon: bool

Specifies if the ExpansionTile should build a default trailing icon if trailing is None.

§initially_expanded: bool

Specifies if the list tile is initially expanded (true) or collapsed (false).

Alternatively, a provided controller can be used to initially expand the tile if ExpansibleController::expand is called before this widget is built.

Defaults to false.

§maintain_state: bool

Specifies whether the state of the children is maintained when the tile expands and collapses.

When true, the children are kept in the tree while the tile is collapsed. When false (default), the children are removed from the tree when the tile is collapsed and recreated upon expansion.

§tile_padding: Option<EdgeInsetsGeometry>

Specifies padding for the ListTile.

Analogous to ListTile::content_padding, this property defines the insets for the leading, title, subtitle and trailing widgets. It does not inset the expanded children widgets.

If this property is None then ExpansionTileThemeData::tile_padding is used. If that is also None then the tile’s padding is EdgeInsets.symmetric(horizontal: 16.0).

See also:

§expanded_alignment: Option<AlignmentGeometry>

Specifies the alignment of children, which are arranged in a column when the tile is expanded.

The internals of the expanded tile make use of a Column widget for children, and Align widget to align the column. The expanded_alignment parameter is passed directly into the Align.

Modifying this property controls the alignment of the column within the expanded tile, not the alignment of children widgets within the column. To align each child within children, see expanded_cross_axis_alignment.

The width of the column is the width of the widest child widget in children.

If this property is None then ExpansionTileThemeData::expanded_alignmentis used. If that is also None then the value of expanded_alignment is Alignment::CENTER.

See also:

§expanded_cross_axis_alignment: Option<CrossAxisAlignment>

Specifies the alignment of each child within children when the tile is expanded.

The internals of the expanded tile make use of a Column widget for children, and the cross_axis_alignment parameter is passed directly into the Column.

Modifying this property controls the cross axis alignment of each child within its Column. The width of the Column that houses children will be the same as the widest child widget in children. The width of the Column might not be equal to the width of the expanded tile.

To align the Column along the expanded tile, use the expanded_alignment property instead.

When the value is None, the value of expanded_cross_axis_alignment is CrossAxisAlignment::Center.

§children_padding: Option<EdgeInsetsGeometry>

Specifies padding for children.

If this property is None then ExpansionTileThemeData::children_padding is used. If that is also None then the value of children_padding is EdgeInsets.zero.

See also:

§icon_color: Option<Color>

The icon color of tile’s expansion arrow icon when the sublist is expanded.

Used to override to the ListTileThemeData::icon_color.

If this property is None then ExpansionTileThemeData::icon_color is used. If that is also None then the value of ColorScheme::primary is used.

See also:

§collapsed_icon_color: Option<Color>

The icon color of tile’s expansion arrow icon when the sublist is collapsed.

Used to override to the ListTileThemeData::icon_color.

If this property is None then ExpansionTileThemeData::collapsed_icon_color is used. If that is also None and ThemeData::use_material3 is true, ColorScheme::on_surface is used. Otherwise, defaults to ThemeData::unselected_widget_color color.

See also:

§text_color: Option<Color>

The color of the tile’s titles when the sublist is expanded.

Used to override to the ListTileThemeData::text_color.

If this property is None then ExpansionTileThemeData::text_color is used. If that is also None then and ThemeData::use_material3 is true, color of the TextTheme::body_large will be used for the title and subtitle. Otherwise, defaults to ColorScheme::primary color.

See also:

§collapsed_text_color: Option<Color>

The color of the tile’s titles when the sublist is collapsed.

Used to override to the ListTileThemeData::text_color.

If this property is None then ExpansionTileThemeData::collapsed_text_color is used. If that is also None and ThemeData::use_material3 is true, color of the TextTheme::body_large will be used for the title and subtitle. Otherwise, defaults to color of the TextTheme::title_medium.

See also:

§shape: Option<ShapeBorderRef>

The tile’s border shape when the sublist is expanded.

If this property is None, the ExpansionTileThemeData::shape is used. If that is also None, a Border with vertical sides default to ThemeData::divider_color is used

See also:

§collapsed_shape: Option<ShapeBorderRef>

The tile’s border shape when the sublist is collapsed.

If this property is None, the ExpansionTileThemeData::collapsed_shape is used. If that is also None, a Border with vertical sides default to Color Colors::TRANSPARENT is used

See also:

§clip_behavior: Option<Clip>

The content will be clipped (or not) according to this option.

If this is not None and a custom collapsed or expanded shape is provided, the value of clip_behavior will be used to clip the expansion tile.

If this property is None, the ExpansionTileThemeData::clip_behavior is used. If that is also None, defaults to Clip::AntiAlias.

See also:

§control_affinity: Option<ListTileControlAffinity>

Typically used to force the expansion arrow icon to the tile’s leading or trailing edge.

By default, the value of control_affinity is ListTileControlAffinity::Platform, which means that the expansion arrow icon will appear on the tile’s trailing edge.

§controller: Option<Ref<ExpansibleController>>

If provided, the controller can be used to expand and collapse tiles.

In cases where control over the tile’s state is needed from a callback triggered by a widget within the tile, ExpansibleController::of may be more convenient than supplying a controller.

§dense: Option<bool>

Whether this list tile is part of a vertically dense list.

If this property is None then its value is based on ListTileThemeData::dense.

Dense list tiles default to a smaller height.

§splash_color: Option<Color>

The splash color of the ink response when the tile is tapped.

This color is passed directly to the underlying ListTile’s splash_color property, which controls the ink ripple (splash) animation when the tile is tapped. Internally, ListTile uses an InkWell (which handles the actual splash effect), and so the provided color will apply to that ripple.

If None, the splash color will default to the current theme’s ThemeData::splash_color.

See also:

  • ListTile::splash_color, which sets the ink splash for the tile.
  • InkWell::splash_color, which determines the color of the ripple effect in Material widgets.
  • ThemeData::splash_color, which provides a fallback color.
§visual_density: Option<VisualDensity>

Defines how compact the expansion tile’s layout will be.

Compactness for components is defined by VisualDensity; see ThemeData::visual_density.

§min_tile_height: Option<f64>

The minimum height allocated for the ListTile widget.

If this is None, default tile heights are 56.0, 72.0, and 88.0 for one, two, and three lines of text respectively. If ListTile::dense is true, these defaults are changed to 48.0, 64.0, and 76.0.

§enable_feedback: Option<bool>

Whether detected gestures should provide acoustic and/or haptic feedback.

For example, on Android a tap will produce a clicking sound and a long-press will produce a short vibration, when feedback is enabled.

When ListTile::enable_feedback is None, ListTileThemeData::enable_feedback is used; when that is also None, the default is true.

§enabled: bool

Whether this expansion tile is interactive.

If false, the internal ListTile will be disabled, changing its appearance according to the theme and disabling user interaction.

Even if disabled, the expansion can still be toggled programmatically through an ExpansionTileController.

§expansion_animation_style: Option<AnimationStyle>

Used to override the expansion animation curve and duration.

If AnimationStyle::duration is provided, it will be used to override the expansion animation duration. If it is None, then AnimationStyle::duration from the ExpansionTileThemeData::expansion_animation_style will be used. Otherwise, defaults to 200ms.

If AnimationStyle::curve is provided, it will be used to override the expansion animation curve. If it is None, then AnimationStyle::curve from the ExpansionTileThemeData::expansion_animation_style will be used. Otherwise, defaults to Curves::ease_in.

If AnimationStyle::reverse_curve is provided, it will be used to override the collapse animation curve. If it is None, then AnimationStyle::reverse_curve from the ExpansionTileThemeData::expansion_animation_style will be used. Otherwise, the same curve will be used as for expansion.

To disable the theme animation, use AnimationStyle::NO_ANIMATION.

§internal_add_semantic_for_on_tap: bool

Whether to add button:true to the semantics if onTap is provided. This is a temporary flag to help changing the behavior of ListTile onTap semantics.

§states_controller: Option<Ref<WidgetStatesController>>

The controller that notifies when the widget’s WidgetStates change.

This allows listening to and controlling states such as WidgetState::Hovered, WidgetState::Focused, WidgetState::Pressed, and WidgetState::Disabled for the tile’s header.

If None, the backing ListTile will create and manage its own WidgetStatesController.

Implementations§

Source§

impl ExpansionTile

Source

pub fn new<K>(title: impl IntoWidget<K>) -> ExpansionTile

Creates a single-line ListTile with an expansion arrow icon that expands or collapses the tile to reveal or hide the children; Dart’s optional named arguments are the setters.

Source

pub fn key(self, key: KeyRef) -> ExpansionTile

Dart ExpansionTile(key:).

Source

pub fn leading<K>(self, leading: impl IntoWidget<K>) -> ExpansionTile

Dart ExpansionTile(leading:).

Source

pub fn subtitle<K>(self, subtitle: impl IntoWidget<K>) -> ExpansionTile

Dart ExpansionTile(subtitle:).

Source

pub fn on_expansion_changed( self, on_expansion_changed: ValueChanged<bool>, ) -> ExpansionTile

Dart ExpansionTile(onExpansionChanged:).

Source

pub fn children( self, children: impl IntoIterator<Item = WidgetRef>, ) -> ExpansionTile

Dart ExpansionTile(children:).

Source

pub fn trailing<K>(self, trailing: impl IntoWidget<K>) -> ExpansionTile

Dart ExpansionTile(trailing:).

Source

pub fn show_trailing_icon(self, show_trailing_icon: bool) -> ExpansionTile

Dart ExpansionTile(showTrailingIcon:).

Source

pub fn initially_expanded(self, initially_expanded: bool) -> ExpansionTile

Dart ExpansionTile(initiallyExpanded:).

Source

pub fn maintain_state(self, maintain_state: bool) -> ExpansionTile

Dart ExpansionTile(maintainState:).

Source

pub fn tile_padding( self, tile_padding: impl Into<EdgeInsetsGeometry>, ) -> ExpansionTile

Dart ExpansionTile(tilePadding:).

Source

pub fn expanded_cross_axis_alignment( self, expanded_cross_axis_alignment: CrossAxisAlignment, ) -> ExpansionTile

Dart ExpansionTile(expandedCrossAxisAlignment:).

Source

pub fn expanded_alignment( self, expanded_alignment: impl Into<AlignmentGeometry>, ) -> ExpansionTile

Dart ExpansionTile(expandedAlignment:).

Source

pub fn children_padding( self, children_padding: impl Into<EdgeInsetsGeometry>, ) -> ExpansionTile

Dart ExpansionTile(childrenPadding:).

Source

pub fn background_color(self, background_color: Color) -> ExpansionTile

Dart ExpansionTile(backgroundColor:).

Source

pub fn collapsed_background_color( self, collapsed_background_color: Color, ) -> ExpansionTile

Dart ExpansionTile(collapsedBackgroundColor:).

Source

pub fn text_color(self, text_color: Color) -> ExpansionTile

Dart ExpansionTile(textColor:).

Source

pub fn collapsed_text_color(self, collapsed_text_color: Color) -> ExpansionTile

Dart ExpansionTile(collapsedTextColor:).

Source

pub fn icon_color(self, icon_color: Color) -> ExpansionTile

Dart ExpansionTile(iconColor:).

Source

pub fn collapsed_icon_color(self, collapsed_icon_color: Color) -> ExpansionTile

Dart ExpansionTile(collapsedIconColor:).

Source

pub fn shape(self, shape: impl Into<ShapeBorderRef>) -> ExpansionTile

Dart ExpansionTile(shape:).

Source

pub fn collapsed_shape( self, collapsed_shape: impl Into<ShapeBorderRef>, ) -> ExpansionTile

Dart ExpansionTile(collapsedShape:).

Source

pub fn clip_behavior(self, clip_behavior: Clip) -> ExpansionTile

Dart ExpansionTile(clipBehavior:).

Source

pub fn control_affinity( self, control_affinity: ListTileControlAffinity, ) -> ExpansionTile

Dart ExpansionTile(controlAffinity:).

Source

pub fn controller(self, controller: Ref<ExpansibleController>) -> ExpansionTile

Dart ExpansionTile(controller:).

Source

pub fn dense(self, dense: bool) -> ExpansionTile

Dart ExpansionTile(dense:).

Source

pub fn splash_color(self, splash_color: Color) -> ExpansionTile

Dart ExpansionTile(splashColor:).

Source

pub fn visual_density(self, visual_density: VisualDensity) -> ExpansionTile

Dart ExpansionTile(visualDensity:).

Source

pub fn min_tile_height(self, min_tile_height: f64) -> ExpansionTile

Dart ExpansionTile(minTileHeight:).

Source

pub fn enable_feedback(self, enable_feedback: bool) -> ExpansionTile

Dart ExpansionTile(enableFeedback:).

Source

pub fn enabled(self, enabled: bool) -> ExpansionTile

Dart ExpansionTile(enabled:).

Source

pub fn expansion_animation_style( self, expansion_animation_style: AnimationStyle, ) -> ExpansionTile

Dart ExpansionTile(expansionAnimationStyle:).

Source

pub fn internal_add_semantic_for_on_tap( self, internal_add_semantic_for_on_tap: bool, ) -> ExpansionTile

Dart ExpansionTile(internalAddSemanticForOnTap:).

Source

pub fn states_controller( self, states_controller: Ref<WidgetStatesController>, ) -> ExpansionTile

Dart ExpansionTile(statesController:).

Trait Implementations§

Source§

impl Debug for ExpansionTile

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl StatefulWidget for ExpansionTile

Source§

type State = ExpansionTileState

The state this widget creates.
Source§

fn key(&self) -> Option<&KeyRef>

Source§

fn create_state(&self) -> ExpansionTileState

Creates the mutable state for this widget at a given location in the tree. Read more
Source§

fn debug_fill_properties( &self, _app: &App, properties: &mut DiagnosticPropertiesBuilder, )

Dart’s debugFillProperties: the properties a dump shows for this widget, in Dart’s order. Dart’s Widget base only sets the dense tree style, which the framework does.
Source§

fn debug_check_constructor(&self)

Source§

fn as_preferred_size_widget( &self, ) -> Option<&(dyn PreferredSizeWidget + 'static)>

Source§

fn type_name(&self) -> &'static str

See Widget::type_name. A stateful form another widget kind becomes (an animated or status transition widget) names the widget it wraps.

Auto Trait Implementations§

§

impl !RefUnwindSafe for ExpansionTile

§

impl !Send for ExpansionTile

§

impl !Sync for ExpansionTile

§

impl !UnwindSafe for ExpansionTile

§

impl Forget for ExpansionTile

§

impl Freeze for ExpansionTile
where *const RcInner<dyn Key> is !null: Freeze, PhantomData<RcInner<dyn Key>>: Freeze, *const RcInner<dyn Widget> is !null: Freeze, PhantomData<RcInner<dyn Widget>>: Freeze, *const RcInner<dyn Fn(&mut App, bool)> is !null: Freeze, PhantomData<RcInner<dyn Fn(&mut App, bool)>>: Freeze, *const u8 is !null: Freeze, PhantomData<Rc<dyn Widget>>: Freeze, *const RcInner<dyn ShapeBorder> is !null: Freeze, PhantomData<RcInner<dyn ShapeBorder>>: Freeze, NonZero<u32>: Freeze, PhantomData<fn() -> ExpansibleController>: Freeze, *const RcInner<Keep> is !null: Freeze, PhantomData<RcInner<Keep>>: Freeze, *const RcInner<dyn Curve> is !null: Freeze, PhantomData<RcInner<dyn Curve>>: Freeze, PhantomData<fn() -> WidgetStatesController>: Freeze,

§

impl Move for ExpansionTile

§

impl Unpin for ExpansionTile
where Rc<dyn Key>: Unpin, Rc<dyn Widget>: Unpin, Rc<dyn Fn(&mut App, bool)>: Unpin, *const u8 is !null: Unpin, Rc<dyn ShapeBorder>: Unpin, NonZero<u32>: Unpin, Rc<Keep>: Unpin, Rc<dyn Curve>: Unpin,

§

impl UnsafeUnpin for ExpansionTile
where *const RcInner<dyn Key> is !null: UnsafeUnpin, PhantomData<RcInner<dyn Key>>: UnsafeUnpin, *const RcInner<dyn Widget> is !null: UnsafeUnpin, PhantomData<RcInner<dyn Widget>>: UnsafeUnpin, *const RcInner<dyn Fn(&mut App, bool)> is !null: UnsafeUnpin, PhantomData<RcInner<dyn Fn(&mut App, bool)>>: UnsafeUnpin, *const u8 is !null: UnsafeUnpin, PhantomData<Rc<dyn Widget>>: UnsafeUnpin, *const RcInner<dyn ShapeBorder> is !null: UnsafeUnpin, PhantomData<RcInner<dyn ShapeBorder>>: UnsafeUnpin, NonZeroU32Inner: UnsafeUnpin, PhantomData<fn() -> ExpansibleController>: UnsafeUnpin, *const RcInner<Keep> is !null: UnsafeUnpin, PhantomData<RcInner<Keep>>: UnsafeUnpin, *const RcInner<dyn Curve> is !null: UnsafeUnpin, PhantomData<RcInner<dyn Curve>>: UnsafeUnpin, PhantomData<fn() -> WidgetStatesController>: UnsafeUnpin,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<W> IntoWidget<StatefulKind> for W
where W: StatefulWidget,

Source§

fn into_widget(self) -> Rc<dyn Widget>

The widget as a tree node, made where this is called: its creation_location.
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>