Skip to main content

SizeTransition

Struct SizeTransition 

Source
pub struct SizeTransition {
    pub key: Option<KeyRef>,
    pub axis: Axis,
    pub size_factor: AnimationRef<f64>,
    pub axis_alignment: Option<f64>,
    pub alignment: Option<AlignmentGeometry>,
    pub fixed_cross_axis_size_factor: Option<f64>,
    pub child: Option<WidgetRef>,
}
Expand description

Animates its own size and clips and aligns its child.

SizeTransition acts as a ClipRect that animates either its width or its height, depending upon the value of axis. The alignment of the child is specified by the alignment.

Like most widgets, SizeTransition will conform to the constraints it is given, so be sure to put it in a context where it can change size. For instance, if you place it into a Container with a fixed size, then the SizeTransition will not be able to change size, and will appear to do nothing.

See also:

  • AnimatedCrossFade, for a widget that automatically animates between the sizes of two children, fading between them.
  • ScaleTransition, a widget that scales the size of the child instead of clipping it.
  • PositionedTransition, a widget that animates its child from a start position to an end position over the lifetime of the animation.
  • RelativePositionedTransition, a widget that transitions its child’s position based on the value of a rectangle relative to a bounding box.

Fields§

§key: Option<KeyRef>§axis: Axis

Axis::Horizontal if size_factor modifies the width, otherwise Axis::Vertical.

§size_factor: AnimationRef<f64>

The animation that controls the (clipped) size of the child.

The width or height (depending on the axis value) of this widget will be its intrinsic width or height multiplied by size_factor’s value at the current point in the animation.

If the value of size_factor is less than one, the child will be clipped in the appropriate axis.

§axis_alignment: Option<f64>
👎Deprecated:

Use alignment instead. This property provides full control over both axes, which is an improvement over the old axisAlignment. This feature was deprecated after v3.41.0-1.0.pre.

Describes how to align the child along the axis that size_factor is modifying.

A value of -1.0 indicates the top when axis is Axis::Vertical, and the start when axis is Axis::Horizontal. The start is on the left when the text direction in effect is TextDirection::Ltr and on the right when it is TextDirection::Rtl.

A value of 1.0 indicates the bottom or end, depending upon the axis.

A value of 0.0 (the default) indicates the center for either axis value.

This property has been deprecated and superseded by alignment. Existing usages can be migrated as follows:

  • If axis is Axis::Horizontal, replace with AlignmentGeometry::xy(axis_alignment.unwrap_or(0.0), -1.0).
  • If axis is Axis::Vertical, replace with AlignmentGeometry::xy(-1.0, axis_alignment.unwrap_or(0.0)).
§alignment: Option<AlignmentGeometry>

The alignment of the child within the parent during the transition.

§fixed_cross_axis_size_factor: Option<f64>

The factor by which to multiply the cross axis size of the child.

If the value of fixed_cross_axis_size_factor is less than one, the child will be clipped along the appropriate axis.

If None (the default), the cross axis size is as large as the parent.

§child: Option<WidgetRef>

The widget below this widget in the tree.

Implementations§

Source§

impl SizeTransition

Source

pub fn new(size_factor: AnimationRef<f64>) -> SizeTransition

Creates a size transition.

The axis defaults to Axis::Vertical. The alignment defaults to the center of the modified axis, which centers the child within the parent during the transition.

Source

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

Dart SizeTransition(key:).

Source

pub fn axis(self, axis: Axis) -> SizeTransition

Dart SizeTransition(axis:).

Source

pub fn axis_alignment(self, axis_alignment: f64) -> SizeTransition

👎Deprecated:

Use alignment instead. This property provides full control over both axes, which is an improvement over the old axisAlignment. This feature was deprecated after v3.41.0-1.0.pre.

Dart SizeTransition(axisAlignment:).

Source

pub fn alignment(self, alignment: AlignmentGeometry) -> SizeTransition

Dart SizeTransition(alignment:).

Source

pub fn fixed_cross_axis_size_factor( self, fixed_cross_axis_size_factor: f64, ) -> SizeTransition

Dart SizeTransition(fixedCrossAxisSizeFactor:).

Source

pub fn child<K>(self, child: impl IntoWidget<K>) -> SizeTransition

Dart SizeTransition(child:).

Trait Implementations§

Source§

impl AnimatedWidget for SizeTransition

Source§

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

Source§

fn listenable(&self) -> Rc<dyn Listenable>

The Listenable to which this widget is listening. Read more
Source§

fn build(&self, app: &mut App, _context: BuildContext) -> WidgetRef

Override this method to build widgets that depend on the state of the listenable (e.g., the current value of the animation).
Source§

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

Dart’s AnimatedWidget.debugFillProperties, which a subclass’s own body calls where Dart writes super.
Source§

impl Debug for SizeTransition

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for SizeTransition

§

impl !Send for SizeTransition

§

impl !Sync for SizeTransition

§

impl !UnwindSafe for SizeTransition

§

impl Forget for SizeTransition

§

impl Freeze for SizeTransition
where *const RcInner<dyn Key> is !null: Freeze, PhantomData<RcInner<dyn Key>>: Freeze, NonZero<u32>: Freeze, &'static AnimationVTable<f64>: Freeze, *const RcInner<Keep> is !null: Freeze, PhantomData<RcInner<Keep>>: Freeze, *const RcInner<dyn Widget> is !null: Freeze, PhantomData<RcInner<dyn Widget>>: Freeze,

§

impl Move for SizeTransition

§

impl Unpin for SizeTransition
where Rc<dyn Key>: Unpin, NonZero<u32>: Unpin, &'static AnimationVTable<f64>: Unpin, Rc<Keep>: Unpin, Rc<dyn Widget>: Unpin,

§

impl UnsafeUnpin for SizeTransition
where *const RcInner<dyn Key> is !null: UnsafeUnpin, PhantomData<RcInner<dyn Key>>: UnsafeUnpin, NonZeroU32Inner: UnsafeUnpin, &'static AnimationVTable<f64>: UnsafeUnpin, *const RcInner<Keep> is !null: UnsafeUnpin, PhantomData<RcInner<Keep>>: UnsafeUnpin, *const RcInner<dyn Widget> is !null: UnsafeUnpin, PhantomData<RcInner<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<AnimatedKind> for W
where W: AnimatedWidget,

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>