Skip to main content

ExpansibleController

Struct ExpansibleController 

Source
pub struct ExpansibleController { /* private fields */ }
Expand description

A controller for managing the expansion state of an Expansible.

This is a ChangeNotifier that notifies its listeners if the value of is_expanded changes.

This controller provides methods to programmatically expand or collapse the widget, and it allows external components to query the current expansion state.

The controller’s expand and collapse methods cause the Expansible to rebuild, so they may not be called from a build method.

Remember to dispose of the ExpansibleController when it is no longer needed. This will ensure all resources used by the object are discarded.

Implementations§

Source§

impl ExpansibleController

Source

pub fn new(app: &mut App) -> Ref<ExpansibleController>

Creates a controller to be used with Expansible::controller.

Source

pub fn is_expanded(self: Handle<Self>, app: &App) -> bool

Whether the expansible widget built with this controller is in expanded state.

This property doesn’t take the animation into account. It reports true even if the expansion animation is not completed.

To be notified when this property changes, add a listener to the controller.

See also:

  • expand, which expands the expansible widget.
  • collapse, which collapses the expansible widget.
Source

pub fn expand(self: Handle<Self>, app: &mut App)

Expands the Expansible that was built with this controller.

If the widget is already in the expanded state (see is_expanded), calling this method has no effect.

Calling this method may cause the Expansible to rebuild, so it may not be called from a build method.

Calling this method will notify registered listeners of this controller that the expansion state has changed.

See also:

  • collapse, which collapses the expansible widget.
  • is_expanded to check whether the expansible widget is expanded.
Source

pub fn collapse(self: Handle<Self>, app: &mut App)

Collapses the Expansible that was built with this controller.

If the widget is already in the collapsed state (see is_expanded), calling this method has no effect.

Calling this method may cause the Expansible to rebuild, so it may not be called from a build method.

Calling this method will notify registered listeners of this controller that the expansion state has changed.

See also:

Source

pub fn toggle(self: Handle<Self>, app: &mut App)

Convenience method for toggling the current is_expanded status.

Calling this method may cause the Expansible to rebuild, so it may not be called from a build method.

Calling this method will notify registered listeners of this controller that the expansion state has changed.

See also:

Source

pub fn dispose(self: Handle<Self>, app: &mut App)

Discards any resources used by the object.

Source

pub fn of(app: &App, context: BuildContext) -> Handle<ExpansibleController>

Finds the ExpansibleController for the closest Expansible instance that encloses the given context.

If no Expansible encloses the given context, calling this method panics.

To return None if there is no Expansible use maybe_of instead.

Typical usage of the of function is to call it from within the build method of a descendant of an Expansible.

Source

pub fn maybe_of( app: &App, context: BuildContext, ) -> Option<Handle<ExpansibleController>>

Finds the Expansible from the closest instance of this class that encloses the given context and returns its ExpansibleController.

If no Expansible encloses the given context then returns None. To panic instead, use of.

See also:

  • of, a similar function to this one that panics if no Expansible encloses the given context.

Trait Implementations§

Source§

impl ChangeNotifier for ExpansibleController

Source§

fn change_notifier_data(&self) -> &ChangeNotifierData

Source§

fn change_notifier_data_mut(&mut self) -> &mut ChangeNotifierData

Source§

fn will_add_listener(self: Handle<Self>, app: &mut App)

Runs before the listener is stored. Dart overrides of addListener that work before super.addListener go here.
Source§

fn did_remove_listener(self: Handle<Self>, app: &mut App)

Runs after the listener is removed. Dart overrides of removeListener that work after super.removeListener go here.
Source§

impl Debug for ExpansibleController

Source§

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

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

impl Default for ExpansibleController

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

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<T> ListenableObject for T
where T: ChangeNotifier,

Source§

fn add_listener(self: Handle<T>, app: &mut App, listener: Listener)

Register a closure to be called when the object notifies its listeners.
Source§

fn remove_listener(self: Handle<T>, app: &mut App, listener: &Listener)

Remove a previously registered closure from the list of closures that the object notifies.
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>