Skip to main content

Expansible

Struct Expansible 

Source
pub struct Expansible {
    pub key: Option<KeyRef>,
    pub controller: Ref<ExpansibleController>,
    pub header_builder: ExpansibleComponentBuilder,
    pub body_builder: ExpansibleComponentBuilder,
    pub animation_style: Option<AnimationStyle>,
    pub duration: Duration,
    pub curve: Rc<dyn Curve>,
    pub reverse_curve: Option<Rc<dyn Curve>>,
    pub maintain_state: bool,
    pub expansible_builder: ExpansibleBuilder,
}
Expand description

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 header_builder and body_builder callbacks to build the header and body widgets. An additional expansible_builder 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 header_builder is tapped.

See also:

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

Fields§

§key: Option<KeyRef>§controller: Ref<ExpansibleController>

Expands and collapses the widget.

The controller manages the expansion state and toggles the expansion.

§header_builder: ExpansibleComponentBuilder

Builds the always-displayed header.

Many use cases involve toggling the expansion state when this header is tapped. To toggle the expansion state, call ExpansibleController::expand or ExpansibleController::collapse.

§body_builder: ExpansibleComponentBuilder

Builds the collapsible body.

When this widget is expanded, the height of its body animates from 0 to its fully extended height.

§animation_style: Option<AnimationStyle>

Used to override the expansion animation curve and duration.

If AnimationStyle::duration is provided, it will be used instead of duration. If not provided, duration is used, which defaults to 200ms.

If AnimationStyle::curve is provided, it will be used to override curve. If it is None, then curve will be used. Otherwise, defaults to Curves::ease.

If AnimationStyle::reverse_curve is provided, it will be used to override reverse_curve. If it is None, then reverse_curve will be used.

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

§duration: Duration
👎Deprecated:

Use animation_style instead. This feature was deprecated after v3.38.0-0.2.pre.

The duration of the expansion animation.

Defaults to a duration of 200ms.

This property is deprecated, use animation_style instead.

§curve: Rc<dyn Curve>
👎Deprecated:

Use animation_style instead. This feature was deprecated after v3.38.0-0.2.pre.

The curve of the expansion animation.

Defaults to Curves::ease.

This property is deprecated, use animation_style instead.

§reverse_curve: Option<Rc<dyn Curve>>
👎Deprecated:

Use animation_style instead. This feature was deprecated after v3.38.0-0.2.pre.

The reverse curve of the expansion animation.

If None, uses curve in both directions.

This property is deprecated, use animation_style instead.

§maintain_state: bool

Whether the state of the body is maintained when the widget expands or collapses.

If true, the body is kept in the tree while the widget is collapsed. Otherwise, the body is removed from the tree when the widget is collapsed and recreated upon expansion.

Defaults to true.

§expansible_builder: ExpansibleBuilder

Builds the widget with the results of header_builder and body_builder.

Defaults to placing the header and body in a Column.

Implementations§

Source§

impl Expansible

Source

pub fn new( header_builder: ExpansibleComponentBuilder, body_builder: ExpansibleComponentBuilder, controller: Ref<ExpansibleController>, ) -> Expansible

Creates an instance of Expansible; Dart’s optional named arguments are the setters.

Source

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

Dart Expansible(key:).

Source

pub fn expansible_builder( self, expansible_builder: ExpansibleBuilder, ) -> Expansible

Dart Expansible(expansibleBuilder:).

Source

pub fn animation_style(self, animation_style: AnimationStyle) -> Expansible

Dart Expansible(animationStyle:).

Source

pub fn duration(self, duration: Duration) -> Expansible

👎Deprecated:

Use animation_style instead. This feature was deprecated after v3.38.0-0.2.pre.

Dart Expansible(duration:).

Source

pub fn curve(self, curve: Rc<dyn Curve>) -> Expansible

👎Deprecated:

Use animation_style instead. This feature was deprecated after v3.38.0-0.2.pre.

Dart Expansible(curve:).

Source

pub fn reverse_curve(self, reverse_curve: Rc<dyn Curve>) -> Expansible

👎Deprecated:

Use animation_style instead. This feature was deprecated after v3.38.0-0.2.pre.

Dart Expansible(reverseCurve:).

Source

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

Dart Expansible(maintainState:).

Trait Implementations§

Source§

impl Debug for Expansible

Source§

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

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

impl StatefulWidget for Expansible

Source§

type State = ExpansibleState

The state this widget creates.
Source§

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

Source§

fn create_state(&self) -> ExpansibleState

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>

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 Expansible

§

impl !Send for Expansible

§

impl !Sync for Expansible

§

impl !UnwindSafe for Expansible

§

impl Forget for Expansible

§

impl Freeze for Expansible
where *const RcInner<dyn Key> is !null: Freeze, PhantomData<RcInner<dyn Key>>: Freeze, NonZero<u32>: Freeze, PhantomData<fn() -> ExpansibleController>: Freeze, *const RcInner<Keep> is !null: Freeze, PhantomData<RcInner<Keep>>: Freeze, *const RcInner<dyn Fn(&mut App, AnyElement, Retained<AnyAnimation<f64>>) -> Rc<dyn Widget>> is !null: Freeze, PhantomData<RcInner<dyn Fn(&mut App, AnyElement, Retained<AnyAnimation<f64>>) -> Rc<dyn Widget>>>: Freeze, *const RcInner<dyn Curve> is !null: Freeze, PhantomData<RcInner<dyn Curve>>: Freeze, *const RcInner<dyn Fn(&mut App, AnyElement, &Rc<dyn Widget>, &Rc<dyn Widget>, Retained<AnyAnimation<f64>>) -> Rc<dyn Widget>> is !null: Freeze, PhantomData<RcInner<dyn Fn(&mut App, AnyElement, &Rc<dyn Widget>, &Rc<dyn Widget>, Retained<AnyAnimation<f64>>) -> Rc<dyn Widget>>>: Freeze,

§

impl Move for Expansible

§

impl Unpin for Expansible
where Rc<dyn Key>: Unpin, NonZero<u32>: Unpin, Rc<Keep>: Unpin, Rc<dyn Fn(&mut App, AnyElement, Retained<AnyAnimation<f64>>) -> Rc<dyn Widget>>: Unpin, Rc<dyn Curve>: Unpin, Rc<dyn Fn(&mut App, AnyElement, &Rc<dyn Widget>, &Rc<dyn Widget>, Retained<AnyAnimation<f64>>) -> Rc<dyn Widget>>: Unpin,

§

impl UnsafeUnpin for Expansible
where *const RcInner<dyn Key> is !null: UnsafeUnpin, PhantomData<RcInner<dyn Key>>: UnsafeUnpin, NonZeroU32Inner: UnsafeUnpin, PhantomData<fn() -> ExpansibleController>: UnsafeUnpin, *const RcInner<Keep> is !null: UnsafeUnpin, PhantomData<RcInner<Keep>>: UnsafeUnpin, *const RcInner<dyn Fn(&mut App, AnyElement, Retained<AnyAnimation<f64>>) -> Rc<dyn Widget>> is !null: UnsafeUnpin, PhantomData<RcInner<dyn Fn(&mut App, AnyElement, Retained<AnyAnimation<f64>>) -> Rc<dyn Widget>>>: UnsafeUnpin, *const RcInner<dyn Curve> is !null: UnsafeUnpin, PhantomData<RcInner<dyn Curve>>: UnsafeUnpin, *const RcInner<dyn Fn(&mut App, AnyElement, &Rc<dyn Widget>, &Rc<dyn Widget>, Retained<AnyAnimation<f64>>) -> Rc<dyn Widget>> is !null: UnsafeUnpin, PhantomData<RcInner<dyn Fn(&mut App, AnyElement, &Rc<dyn Widget>, &Rc<dyn Widget>, Retained<AnyAnimation<f64>>) -> Rc<dyn Widget>>>: 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>