pub struct FadeTransition {
pub key: Option<KeyRef>,
pub opacity: AnimationRef<f64>,
pub child: Option<WidgetRef>,
}Expand description
Animates the opacity of a widget.
For a widget that automatically animates between the sizes of two children,
fading between them, see AnimatedCrossFade.
§Hit testing
Setting the opacity to zero does not prevent hit testing from being
applied to the descendants of the FadeTransition widget. This can be
confusing for the user, who may not see anything, and may believe the area
of the interface where the FadeTransition is hiding a widget to be
non-interactive.
With certain widgets, such as Flow, that compute their positions only when
they are painted, this can actually lead to bugs (from unexpected geometry
to exceptions), because those widgets are not painted by the
FadeTransition widget at all when the opacity animation reaches
zero.
To avoid such problems, it is generally a good idea to combine this widget
with an IgnorePointer that one enables when the opacity animation
reaches zero. This prevents interactions with any children in the subtree
when the child is not visible. For performance reasons, when
implementing this, care should be taken not to rebuild the relevant widget (e.g. by
calling State::set_state) except at the transition point.
See also:
Opacity, which does not animate changes in opacity.AnimatedOpacity, which animates changes in opacity without taking an explicitAnimationargument.
Fields§
§key: Option<KeyRef>See Widget::key.
opacity: AnimationRef<f64>The animation that controls the opacity of the child.
If the current value of the opacity animation is v, the child will be painted with an opacity of v. For example, if v is 0.5, the child will be blended 50% with its background. Similarly, if v is 0.0, the child will be completely transparent.
child: Option<WidgetRef>The widget below this widget in the tree.
Implementations§
Source§impl FadeTransition
impl FadeTransition
Sourcepub fn new(opacity: AnimationRef<f64>) -> FadeTransition
pub fn new(opacity: AnimationRef<f64>) -> FadeTransition
Creates an opacity transition.
Sourcepub fn key(self, key: KeyRef) -> FadeTransition
pub fn key(self, key: KeyRef) -> FadeTransition
Dart FadeTransition(key:).
Sourcepub fn child<K>(self, child: impl IntoWidget<K>) -> FadeTransition
pub fn child<K>(self, child: impl IntoWidget<K>) -> FadeTransition
Dart FadeTransition(child:).
Trait Implementations§
Source§impl Debug for FadeTransition
impl Debug for FadeTransition
Source§impl RenderObjectWidget for FadeTransition
impl RenderObjectWidget for FadeTransition
Source§type RenderObject = RenderAnimatedOpacity
type RenderObject = RenderAnimatedOpacity
covariant RenderObject parameter type.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_render_object(
&self,
app: &mut App,
_context: BuildContext,
) -> AnyRenderObject
fn create_render_object( &self, app: &mut App, _context: BuildContext, ) -> AnyRenderObject
RenderObject class that this widget represents, using the
configuration described by this widget. Read moreSource§fn update_render_object(
&self,
app: &mut App,
_context: BuildContext,
render_object: RenderHandle<RenderAnimatedOpacity>,
)
fn update_render_object( &self, app: &mut App, _context: BuildContext, render_object: RenderHandle<RenderAnimatedOpacity>, )
create_render_object. Read moreSource§fn to_string_short(&self) -> String
fn to_string_short(&self) -> String
toStringShort, for a widget that names itself apart from its type, as
SizedBox.expand does; see Widget::to_string_short.Source§fn debug_visit_onstage_children(
&self,
app: &App,
children: &[AnyElement],
visitor: &mut dyn FnMut(AnyElement),
)
fn debug_visit_onstage_children( &self, app: &App, children: &[AnyElement], visitor: &mut dyn FnMut(AnyElement), )
debugVisitOnstageChildren of the element this widget makes, for a widget whose
Dart element subclass overrides it only to hide children (_OffstageElement,
_IndexedStackElement): calls visitor for each of children, in order, that is
onstage. Waft’s generic single- and multi-child elements stand in for those subclasses
and ask their widget here; an element of a widget’s own overrides
Element::debug_visit_onstage_children instead.Source§fn did_unmount_render_object(
&self,
app: &mut App,
render_object: RenderHandle<Self::RenderObject>,
)
fn did_unmount_render_object( &self, app: &mut App, render_object: RenderHandle<Self::RenderObject>, )
RenderObject will be of the same type as returned by this object’s
create_render_object.Auto Trait Implementations§
impl !RefUnwindSafe for FadeTransition
impl !Send for FadeTransition
impl !Sync for FadeTransition
impl !UnwindSafe for FadeTransition
impl Forget for FadeTransition
impl Freeze for FadeTransitionwhere
*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 FadeTransition
impl Unpin for FadeTransition
impl UnsafeUnpin for FadeTransitionwhere
*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> 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<SingleChildRenderObjectKind> for Wwhere
W: SingleChildRenderObjectWidget,
<W as RenderObjectWidget>::RenderObject: RenderObjectWithChildMixin,
impl<W> IntoWidget<SingleChildRenderObjectKind> for Wwhere
W: SingleChildRenderObjectWidget,
<W as RenderObjectWidget>::RenderObject: RenderObjectWithChildMixin,
Source§fn into_widget(self) -> Rc<dyn Widget>
fn into_widget(self) -> Rc<dyn Widget>
creation_location.