Skip to main content

AnimatedContainer

Struct AnimatedContainer 

Source
pub struct AnimatedContainer {
    pub alignment: Option<AlignmentGeometry>,
    pub padding: Option<EdgeInsetsGeometry>,
    pub decoration: Option<DecorationRef>,
    pub foreground_decoration: Option<DecorationRef>,
    pub constraints: Option<BoxConstraints>,
    pub margin: Option<EdgeInsetsGeometry>,
    pub transform: Option<Matrix4>,
    pub transform_alignment: Option<AlignmentGeometry>,
    pub child: Option<WidgetRef>,
    pub clip_behavior: Clip,
    /* private fields */
}
Expand description

A container that gradually changes its values over a period of time.

The AnimatedContainer will automatically animate between the old and new values of properties when they change using the provided curve and duration. Properties that are null are not animated. Its child and descendants are not animated.

This class is useful for generating simple implicit transitions between different parameters to Container with its internal AnimationController. For more complex animations, you’ll likely want to use a subclass of Transition such as the DecoratedBoxTransition or use your own AnimationController.

See also:

  • AnimatedPadding, which is a subset of this widget that only supports animating the padding.
  • AnimatedPositioned, which, as a child of a Stack, automatically transitions its child’s position over a given duration whenever the given position changes.
  • AnimatedAlign, which automatically transitions its child’s position over a given duration whenever the given AnimatedAlign::alignment changes.

Fields§

§alignment: Option<AlignmentGeometry>

Align the child within the container.

If non-None, the container will expand to fill its parent and position its child within itself according to the given value. If the incoming constraints are unbounded, then the child will be shrink-wrapped instead.

Ignored if child is None.

§padding: Option<EdgeInsetsGeometry>

Empty space to inscribe inside the decoration. The child, if any, is placed inside this padding.

§decoration: Option<DecorationRef>

The decoration to paint behind the child.

A shorthand for specifying just a solid color is available in color.

§foreground_decoration: Option<DecorationRef>

The decoration to paint in front of the child.

§constraints: Option<BoxConstraints>

Additional constraints to apply to the child.

The width and height setters are combined with the given constraints: this is Dart’s folded field.

The padding goes inside the constraints.

§margin: Option<EdgeInsetsGeometry>

Empty space to surround the decoration and child.

§transform: Option<Matrix4>

The transformation matrix to apply before painting the container.

§transform_alignment: Option<AlignmentGeometry>

The alignment of the origin, relative to the size of the container, if transform is specified.

When transform is None, the value of this property is ignored.

§child: Option<WidgetRef>

The child contained by the container.

If None, and if the constraints are unbounded or also None, the container will expand to fill all available space in its parent, unless the parent provides unbounded constraints, in which case the container will attempt to be as small as possible.

§clip_behavior: Clip

The clip behavior when decoration is not None.

Defaults to Clip::None. Must be Clip::None if decoration is None.

Unlike other properties of AnimatedContainer, changes to this property apply immediately and have no animation.

Implementations§

Source§

impl AnimatedContainer

Source

pub fn new(duration: Duration) -> AnimatedContainer

Creates a container that animates its parameters implicitly.

Source

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

Dart AnimatedContainer(alignment:).

Source

pub fn padding( self, padding: impl Into<EdgeInsetsGeometry>, ) -> AnimatedContainer

Dart AnimatedContainer(padding:); must be non-negative.

Source

pub fn color(self, color: impl Into<AnyColor>) -> AnimatedContainer

Dart AnimatedContainer(color:), the shorthand for a solid-color decoration; cannot be combined with one.

Source

pub fn decoration( self, decoration: impl Into<DecorationRef>, ) -> AnimatedContainer

Dart AnimatedContainer(decoration:); cannot be combined with color.

Source

pub fn foreground_decoration( self, foreground_decoration: impl Into<DecorationRef>, ) -> AnimatedContainer

Dart AnimatedContainer(foregroundDecoration:).

Source

pub fn width(self, width: f64) -> AnimatedContainer

Dart AnimatedContainer(width:): tightens constraints.

Source

pub fn height(self, height: f64) -> AnimatedContainer

Dart AnimatedContainer(height:): tightens constraints.

Source

pub fn constraints(self, constraints: BoxConstraints) -> AnimatedContainer

Dart AnimatedContainer(constraints:); must be valid.

Source

pub fn margin(self, margin: impl Into<EdgeInsetsGeometry>) -> AnimatedContainer

Dart AnimatedContainer(margin:); must be non-negative.

Source

pub fn transform(self, transform: Matrix4) -> AnimatedContainer

Dart AnimatedContainer(transform:).

Source

pub fn transform_alignment( self, transform_alignment: AlignmentGeometry, ) -> AnimatedContainer

Dart AnimatedContainer(transformAlignment:).

Source

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

Dart AnimatedContainer(child:).

Source

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

Dart AnimatedContainer(clipBehavior:).

Source

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

Dart key:.

Source

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

Dart curve:.

Source

pub fn on_end(self, on_end: Listener) -> AnimatedContainer

Dart onEnd:.

Trait Implementations§

Source§

impl Debug for AnimatedContainer

Source§

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

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

impl ImplicitlyAnimatedWidget for AnimatedContainer

Source§

impl StatefulWidget for AnimatedContainer

Source§

type State = AnimatedContainerState

The state this widget creates.
Source§

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

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 create_state(&self) -> AnimatedContainerState

Creates the mutable state for this widget at a given location in the tree. Read more
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 AnimatedContainer

§

impl !Send for AnimatedContainer

§

impl !Sync for AnimatedContainer

§

impl !UnwindSafe for AnimatedContainer

§

impl Forget for AnimatedContainer

§

impl Freeze for AnimatedContainer
where *const RcInner<dyn Key> is !null: Freeze, PhantomData<RcInner<dyn Key>>: Freeze, *const RcInner<dyn Curve> is !null: Freeze, PhantomData<RcInner<dyn Curve>>: Freeze, *const RcInner<dyn Fn(&mut App)> is !null: Freeze, PhantomData<RcInner<dyn Fn(&mut App)>>: Freeze, NonZero<u32>: Freeze, *const (): Freeze, &'static dyn ColorExtension: Freeze, *const RcInner<dyn ColorExtension> is !null: Freeze, PhantomData<RcInner<dyn ColorExtension>>: Freeze, *const RcInner<dyn Decoration> is !null: Freeze, PhantomData<RcInner<dyn Decoration>>: Freeze, *const RcInner<dyn Widget> is !null: Freeze, PhantomData<RcInner<dyn Widget>>: Freeze,

§

impl Move for AnimatedContainer

§

impl Unpin for AnimatedContainer
where Rc<dyn Key>: Unpin, Rc<dyn Curve>: Unpin, Rc<dyn Fn(&mut App)>: Unpin, NonZero<u32>: Unpin, *const (): Unpin, &'static dyn ColorExtension: Unpin, Rc<dyn ColorExtension>: Unpin, Rc<dyn Decoration>: Unpin, Rc<dyn Widget>: Unpin,

§

impl UnsafeUnpin for AnimatedContainer
where *const RcInner<dyn Key> is !null: UnsafeUnpin, PhantomData<RcInner<dyn Key>>: UnsafeUnpin, *const RcInner<dyn Curve> is !null: UnsafeUnpin, PhantomData<RcInner<dyn Curve>>: UnsafeUnpin, *const RcInner<dyn Fn(&mut App)> is !null: UnsafeUnpin, PhantomData<RcInner<dyn Fn(&mut App)>>: UnsafeUnpin, NonZeroU32Inner: UnsafeUnpin, *const (): UnsafeUnpin, &'static dyn ColorExtension: UnsafeUnpin, *const RcInner<dyn ColorExtension> is !null: UnsafeUnpin, PhantomData<RcInner<dyn ColorExtension>>: UnsafeUnpin, *const RcInner<dyn Decoration> is !null: UnsafeUnpin, PhantomData<RcInner<dyn Decoration>>: 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<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>