pub struct AnimatedCrossFade {Show 14 fields
pub key: Option<KeyRef>,
pub first_child: WidgetRef,
pub second_child: WidgetRef,
pub cross_fade_state: CrossFadeState,
pub duration: Duration,
pub reverse_duration: Option<Duration>,
pub first_curve: Rc<dyn Curve>,
pub second_curve: Rc<dyn Curve>,
pub size_curve: Rc<dyn Curve>,
pub alignment: AlignmentGeometry,
pub layout_builder: AnimatedCrossFadeBuilder,
pub exclude_bottom_focus: bool,
pub clip_behavior: Clip,
pub on_end: Option<Listener>,
}Expand description
A widget that cross-fades between two given children and animates itself between their sizes.
The animation is controlled through the cross_fade_state
parameter. first_curve and second_curve
represent the opacity curves of the two children. The
first_curve is inverted, i.e. it fades out when providing a
growing curve like Curves::linear. The size_curve is the curve
used to animate between the size of the fading-out child and the size of the fading-in
child.
This widget is intended to be used to fade a pair of widgets with the same width. In the case where the two children have different heights, the animation crops overflowing children during the animation by aligning their top edge, which means that the bottom will be clipped.
The animation is automatically triggered when an existing
AnimatedCrossFade is rebuilt with a different value for the
cross_fade_state property.
See also:
AnimatedOpacity, which fades between nothing and a single child.AnimatedSwitcher, which switches out a child for a new one with a customizable transition, supporting multiple cross-fades at once.AnimatedSize, the lower-level widget whichAnimatedCrossFadeuses to automatically change size.
Fields§
§key: Option<KeyRef>§first_child: WidgetRefThe child that is visible when cross_fade_state is
CrossFadeState::ShowFirst. It fades out when transitioning
cross_fade_state from CrossFadeState::ShowFirst to
CrossFadeState::ShowSecond and vice versa.
second_child: WidgetRefThe child that is visible when cross_fade_state is
CrossFadeState::ShowSecond. It fades in when transitioning
cross_fade_state from CrossFadeState::ShowFirst to
CrossFadeState::ShowSecond and vice versa.
cross_fade_state: CrossFadeStateThe child that will be shown when the animation has completed.
duration: DurationThe duration of the whole orchestrated animation.
reverse_duration: Option<Duration>The duration of the whole orchestrated animation when running in reverse.
If not supplied, this defaults to duration.
first_curve: Rc<dyn Curve>The fade curve of the first child.
Defaults to Curves::linear.
second_curve: Rc<dyn Curve>The fade curve of the second child.
Defaults to Curves::linear.
size_curve: Rc<dyn Curve>The curve of the animation between the two children’s sizes.
Defaults to Curves::linear.
alignment: AlignmentGeometryHow the children should be aligned while the size is animating.
Defaults to Alignment::TOP_CENTER.
See also:
Alignment, a class with convenient constants typically used to specify anAlignmentGeometry.AlignmentDirectional, likeAlignmentfor specifying alignments relative to text direction.
layout_builder: AnimatedCrossFadeBuilderA builder that positions the first_child and
second_child widgets.
The widget returned by this method is wrapped in an AnimatedSize.
By default, this uses AnimatedCrossFade::default_layout_builder, which uses
a Stack and aligns the bottom_child to the top of the stack while
providing the top_child as the non-positioned child to fill the provided
constraints. This works well when the AnimatedCrossFade is in a position
to change size and when the children are not flexible. However, if the
children are less fussy about their sizes (for example a
CircularProgressIndicator inside a Center), or if the
AnimatedCrossFade is being forced to a particular size, then it can
result in the widgets jumping about when the cross-fade state is changed.
exclude_bottom_focus: boolWhen true, this is equivalent to wrapping the bottom widget with an ExcludeFocus
widget while it is at the bottom of the cross-fade stack.
Defaults to true. When it is false, the bottom widget in the cross-fade stack
can remain in focus until the top widget requests focus. This is useful for
animating between different TextFields so the keyboard remains open during the
cross-fade animation.
clip_behavior: ClipControls whether the content is clipped during the cross-fade transition.
During the size transition between first_child and
second_child, the content is clipped by default to prevent it
from overflowing the bounding box of the animating widget.
Set this to Clip::None to disable clipping entirely. This can be
useful for widgets with shadows or visual effects that extend beyond
their bounds.
Defaults to Clip::HardEdge.
on_end: Option<Listener>Called every time an animation completes.
This can be useful to trigger additional actions (e.g. another animation) at the end of the current animation.
Implementations§
Source§impl AnimatedCrossFade
impl AnimatedCrossFade
Sourcepub fn new<F, S>(
first_child: impl IntoWidget<F>,
second_child: impl IntoWidget<S>,
cross_fade_state: CrossFadeState,
duration: Duration,
) -> AnimatedCrossFade
pub fn new<F, S>( first_child: impl IntoWidget<F>, second_child: impl IntoWidget<S>, cross_fade_state: CrossFadeState, duration: Duration, ) -> AnimatedCrossFade
Creates a cross-fade animation widget.
The duration of the animation is the same for all components (fade
in, fade out, and size), and you can pass Intervals instead of Curves in order to
have finer control, e.g., creating an overlap between the fades.
Sourcepub fn key(self, key: KeyRef) -> AnimatedCrossFade
pub fn key(self, key: KeyRef) -> AnimatedCrossFade
Dart AnimatedCrossFade(key:).
Sourcepub fn reverse_duration(self, reverse_duration: Duration) -> AnimatedCrossFade
pub fn reverse_duration(self, reverse_duration: Duration) -> AnimatedCrossFade
Dart AnimatedCrossFade(reverseDuration:).
Sourcepub fn first_curve(self, first_curve: Rc<dyn Curve>) -> AnimatedCrossFade
pub fn first_curve(self, first_curve: Rc<dyn Curve>) -> AnimatedCrossFade
Dart AnimatedCrossFade(firstCurve:).
Sourcepub fn second_curve(self, second_curve: Rc<dyn Curve>) -> AnimatedCrossFade
pub fn second_curve(self, second_curve: Rc<dyn Curve>) -> AnimatedCrossFade
Dart AnimatedCrossFade(secondCurve:).
Sourcepub fn size_curve(self, size_curve: Rc<dyn Curve>) -> AnimatedCrossFade
pub fn size_curve(self, size_curve: Rc<dyn Curve>) -> AnimatedCrossFade
Dart AnimatedCrossFade(sizeCurve:).
Sourcepub fn alignment(self, alignment: AlignmentGeometry) -> AnimatedCrossFade
pub fn alignment(self, alignment: AlignmentGeometry) -> AnimatedCrossFade
Dart AnimatedCrossFade(alignment:).
Sourcepub fn layout_builder(
self,
layout_builder: impl Fn(&mut App, &WidgetRef, &KeyRef, &WidgetRef, &KeyRef) -> WidgetRef + 'static,
) -> AnimatedCrossFade
pub fn layout_builder( self, layout_builder: impl Fn(&mut App, &WidgetRef, &KeyRef, &WidgetRef, &KeyRef) -> WidgetRef + 'static, ) -> AnimatedCrossFade
Dart AnimatedCrossFade(layoutBuilder:).
Sourcepub fn exclude_bottom_focus(
self,
exclude_bottom_focus: bool,
) -> AnimatedCrossFade
pub fn exclude_bottom_focus( self, exclude_bottom_focus: bool, ) -> AnimatedCrossFade
Dart AnimatedCrossFade(excludeBottomFocus:).
Sourcepub fn clip_behavior(self, clip_behavior: Clip) -> AnimatedCrossFade
pub fn clip_behavior(self, clip_behavior: Clip) -> AnimatedCrossFade
Dart AnimatedCrossFade(clipBehavior:).
Sourcepub fn on_end(self, on_end: Listener) -> AnimatedCrossFade
pub fn on_end(self, on_end: Listener) -> AnimatedCrossFade
Dart AnimatedCrossFade(onEnd:).
Sourcepub fn default_layout_builder(
_app: &mut App,
top_child: &WidgetRef,
top_child_key: &KeyRef,
bottom_child: &WidgetRef,
bottom_child_key: &KeyRef,
) -> WidgetRef
pub fn default_layout_builder( _app: &mut App, top_child: &WidgetRef, top_child_key: &KeyRef, bottom_child: &WidgetRef, bottom_child_key: &KeyRef, ) -> WidgetRef
The default layout algorithm used by AnimatedCrossFade.
The top child is placed in a stack that sizes itself to match the top child. The bottom child is positioned at the top of the same stack, sized to fit its width but without forcing the height. The stack is then clipped.
This is the default value for layout_builder. It implements
AnimatedCrossFadeBuilder.
Trait Implementations§
Source§impl Debug for AnimatedCrossFade
impl Debug for AnimatedCrossFade
Source§impl StatefulWidget for AnimatedCrossFade
impl StatefulWidget for AnimatedCrossFade
Source§type State = AnimatedCrossFadeState
type State = AnimatedCrossFadeState
Source§fn debug_fill_properties(
&self,
_app: &App,
properties: &mut DiagnosticPropertiesBuilder,
)
fn debug_fill_properties( &self, _app: &App, properties: &mut DiagnosticPropertiesBuilder, )
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) -> AnimatedCrossFadeState
fn create_state(&self) -> AnimatedCrossFadeState
Source§fn as_preferred_size_widget(&self) -> Option<&dyn PreferredSizeWidget>
fn as_preferred_size_widget(&self) -> Option<&dyn PreferredSizeWidget>
Source§fn type_name(&self) -> &'static str
fn type_name(&self) -> &'static str
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 AnimatedCrossFade
impl !Send for AnimatedCrossFade
impl !Sync for AnimatedCrossFade
impl !UnwindSafe for AnimatedCrossFade
impl Forget for AnimatedCrossFade
impl Freeze for AnimatedCrossFadewhere
*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 Curve> is !null: Freeze,
PhantomData<RcInner<dyn Curve>>: Freeze,
*const RcInner<dyn Fn(&mut App, &Rc<dyn Widget>, &KeyRef, &Rc<dyn Widget>, &KeyRef) -> Rc<dyn Widget>> is !null: Freeze,
PhantomData<RcInner<dyn Fn(&mut App, &Rc<dyn Widget>, &KeyRef, &Rc<dyn Widget>, &KeyRef) -> Rc<dyn Widget>>>: Freeze,
*const RcInner<dyn Fn(&mut App)> is !null: Freeze,
PhantomData<RcInner<dyn Fn(&mut App)>>: Freeze,
NonZero<u32>: Freeze,
*const (): Freeze,
impl Move for AnimatedCrossFade
impl Unpin for AnimatedCrossFade
impl UnsafeUnpin for AnimatedCrossFadewhere
*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 Curve> is !null: UnsafeUnpin,
PhantomData<RcInner<dyn Curve>>: UnsafeUnpin,
*const RcInner<dyn Fn(&mut App, &Rc<dyn Widget>, &KeyRef, &Rc<dyn Widget>, &KeyRef) -> Rc<dyn Widget>> is !null: UnsafeUnpin,
PhantomData<RcInner<dyn Fn(&mut App, &Rc<dyn Widget>, &KeyRef, &Rc<dyn Widget>, &KeyRef) -> Rc<dyn Widget>>>: UnsafeUnpin,
*const RcInner<dyn Fn(&mut App)> is !null: UnsafeUnpin,
PhantomData<RcInner<dyn Fn(&mut App)>>: UnsafeUnpin,
NonZeroU32Inner: UnsafeUnpin,
*const (): UnsafeUnpin,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<W> IntoWidget<StatefulKind> for Wwhere
W: StatefulWidget,
impl<W> IntoWidget<StatefulKind> for Wwhere
W: StatefulWidget,
Source§fn into_widget(self) -> Rc<dyn Widget>
fn into_widget(self) -> Rc<dyn Widget>
creation_location.