AnimatedVisibility class

Animates child in and out as visible toggles, deferring unmount until the exit effect completes.

When first built with visible true, enter plays. Both effects follow one progress value that runs from 0 (hidden) to 1 (shown). If visible flips back before a transition finishes, that value turns around from where it is instead of restarting, and the other effect takes over: showing the child again during its exit switches to enter at the current progress, rather than playing exit backward.

Inheritance
Available extensions

Constructors

AnimatedVisibility({required bool visible, required Widget child, Effect? enter, Effect? exit, Duration? duration, Curve? curve, Key? key})
const

Properties

child → Widget
The widget to show. It stays mounted while exit plays and is removed when the exit finishes.
final
curve → Curve?
The easing for enter and exit. Defaults to Curves.easeOut.
final
duration → Duration?
How long enter and exit take. Defaults to 250 ms.
final
enter → Effect?
Effect played as the child appears (0 → 1). Null = appear instantly.
final
exit → Effect?
Effect played as the child leaves. Null = unmount immediately, no exit animation.
final
hashCode → int
The hash code for this object.
no setterinherited
key → Key?
finalinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
visible → bool
Whether child is shown. Changing it plays enter or exit.
final

Methods

animate({Duration? duration, Curve? curve, Object? trigger, bool repeat = false}) → Animate

Available on Widget, provided by the AnimateExtension extension

Starts an Animate chain over this widget. duration / curve apply to the whole chain. With no trigger it plays on mount; with a non-null trigger it rests on mount and replays whenever the token changes.
createElement() → StatefulElement
Creates the Element that will mount this widget into the tree.
inherited
createState() → State<AnimatedVisibility>
Creates the mutable state for this widget at the current location in the tree. Called exactly once per StatefulElement instance.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited