AnimatedContainer class
Animated version of 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 AnimatedWidget such as the DecoratedBoxTransition or use your own AnimationController.
{@tool dartpad}
The following example (depicted above) transitions an AnimatedContainer
between two states. It adjusts the height
, width
, color
, and
alignment properties when tapped.
** See code in examples/api/lib/widgets/implicit_animations/animated_container.0.dart ** {@end-tool}
See also:
- AnimatedPadding, which is a subset of this widget that only supports animating the padding.
- The catalog of layout widgets.
- 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.
- AnimatedSwitcher, which switches out a child for a new one with a customizable transition.
- AnimatedCrossFade, which fades between two children and interpolates their sizes.
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatefulWidget
- ImplicitlyAnimatedWidget
- AnimatedContainer
- Available extensions
Constructors
- AnimatedContainer({Key? key, AlignmentGeometry? alignment, EdgeInsetsGeometry? padding, Color? color, Decoration? decoration, Decoration? foregroundDecoration, double? width, double? height, BoxConstraints? constraints, EdgeInsetsGeometry? margin, Matrix4? transform, AlignmentGeometry? transformAlignment, Widget? child, Clip clipBehavior = Clip.none, Curve curve = Curves.linear, required Duration duration, VoidCallback? onEnd})
- Creates a container that animates its parameters implicitly.
Properties
- alignment → AlignmentGeometry?
-
Align the child within the container.
final
- child → Widget?
-
The child contained by the container.
final
- clipBehavior → Clip
-
The clip behavior when AnimatedContainer.decoration is not null.
final
- constraints → BoxConstraints?
-
Additional constraints to apply to the child.
final
- curve → Curve
-
The curve to apply when animating the parameters of this container.
finalinherited
- decoration → Decoration?
-
The decoration to paint behind the child.
final
- duration → Duration
-
The duration over which to animate the parameters of this container.
finalinherited
- foregroundDecoration → Decoration?
-
The decoration to paint in front of the child.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- margin → EdgeInsetsGeometry?
-
Empty space to surround the decoration and child.
final
- onEnd → VoidCallback?
-
Called every time an animation completes.
finalinherited
- padding → EdgeInsetsGeometry?
-
Empty space to inscribe inside the decoration. The child, if any, is
placed inside this padding.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- transform → Matrix4?
-
The transformation matrix to apply before painting the container.
final
- transformAlignment → AlignmentGeometry?
-
The alignment of the origin, relative to the size of the container, if transform is specified.
final
Methods
-
asSkeleton(
{bool enabled = true, bool leaf = false, Widget? replacement, bool unite = false, AsyncSnapshot? snapshot}) → Widget -
Available on Widget, provided by the SkeletonExtension extension
-
asSkeletonSliver(
{bool enabled = true}) → Widget -
Available on Widget, provided by the SkeletonExtension extension
-
base(
) → Widget -
Available on Widget, provided by the TextExtension extension
-
black(
) → Widget -
Available on Widget, provided by the TextExtension extension
-
blockQuote(
) → Widget -
Available on Widget, provided by the TextExtension extension
-
bold(
) → Widget -
Available on Widget, provided by the TextExtension extension
-
center(
{Key? key}) → Widget -
Available on Widget, provided by the WidgetExtension extension
-
clip(
{Clip clipBehavior = Clip.hardEdge}) → Widget -
Available on Widget, provided by the WidgetExtension extension
-
clipOval(
{Clip clipBehavior = Clip.antiAlias}) → Widget -
Available on Widget, provided by the WidgetExtension extension
-
clipPath(
{Clip clipBehavior = Clip.antiAlias, required CustomClipper< Path> clipper}) → Widget -
Available on Widget, provided by the WidgetExtension extension
-
clipRRect(
{BorderRadiusGeometry borderRadius = BorderRadius.zero, Clip clipBehavior = Clip.antiAlias}) → Widget -
Available on Widget, provided by the WidgetExtension extension
-
constrained(
{double? minWidth, double? maxWidth, double? minHeight, double? maxHeight}) → Widget -
Available on Widget, provided by the WidgetExtension extension
-
createElement(
) → StatefulElement -
Creates a StatefulElement to manage this widget's location in the tree.
inherited
-
createState(
) → AnimatedWidgetBaseState< AnimatedContainer> -
Creates the mutable state for this widget at a given location in the tree.
override
-
debugDescribeChildren(
) → List< DiagnosticsNode> -
Returns a list of DiagnosticsNode objects describing this node's
children.
inherited
-
debugFillProperties(
DiagnosticPropertiesBuilder properties) → void -
Add additional properties associated with the node.
override
-
ellipsis(
) → Widget -
Available on Widget, provided by the TextExtension extension
-
excludeSkeleton(
{bool exclude = true}) → Widget -
Available on Widget, provided by the SkeletonExtension extension
-
expanded(
{int flex = 1}) → Widget -
Available on Widget, provided by the WidgetExtension extension
-
extraBold(
) → Widget -
Available on Widget, provided by the TextExtension extension
-
extraLight(
) → Widget -
Available on Widget, provided by the TextExtension extension
-
foreground(
) → Widget -
Available on Widget, provided by the TextExtension extension
-
h1(
) → Widget -
Available on Widget, provided by the TextExtension extension
-
h2(
) → Widget -
Available on Widget, provided by the TextExtension extension
-
h3(
) → Widget -
Available on Widget, provided by the TextExtension extension
-
h4(
) → Widget -
Available on Widget, provided by the TextExtension extension
-
iconDestructiveForeground(
) → Widget -
Available on Widget, provided by the IconExtension extension
-
iconLarge(
) → Widget -
Available on Widget, provided by the IconExtension extension
-
iconMedium(
) → Widget -
Available on Widget, provided by the IconExtension extension
-
iconMutedForeground(
) → Widget -
Available on Widget, provided by the IconExtension extension
-
iconPrimary(
) → Widget -
Available on Widget, provided by the IconExtension extension
-
iconPrimaryForeground(
) → Widget -
Available on Widget, provided by the IconExtension extension
-
iconSecondary(
) → Widget -
Available on Widget, provided by the IconExtension extension
-
iconSecondaryForeground(
) → Widget -
Available on Widget, provided by the IconExtension extension
-
iconSmall(
) → Widget -
Available on Widget, provided by the IconExtension extension
-
iconX2Large(
) → Widget -
Available on Widget, provided by the IconExtension extension
-
iconX2Small(
) → Widget -
Available on Widget, provided by the IconExtension extension
-
iconX3Large(
) → Widget -
Available on Widget, provided by the IconExtension extension
-
iconX3Small(
) → Widget -
Available on Widget, provided by the IconExtension extension
-
iconX4Large(
) → Widget -
Available on Widget, provided by the IconExtension extension
-
iconX4Small(
) → Widget -
Available on Widget, provided by the IconExtension extension
-
iconXLarge(
) → Widget -
Available on Widget, provided by the IconExtension extension
-
iconXSmall(
) → Widget -
Available on Widget, provided by the IconExtension extension
-
ignoreSkeleton(
) → Widget -
Available on Widget, provided by the SkeletonExtension extension
-
inlineCode(
) → Widget -
Available on Widget, provided by the TextExtension extension
-
intrinsic(
{double? stepWidth, double? stepHeight}) → Widget -
Available on Widget, provided by the WidgetExtension extension
-
intrinsicHeight(
) → Widget -
Available on Widget, provided by the WidgetExtension extension
-
intrinsicWidth(
{double? stepWidth, double? stepHeight}) → Widget -
Available on Widget, provided by the WidgetExtension extension
-
italic(
) → Widget -
Available on Widget, provided by the TextExtension extension
-
large(
) → Widget -
Available on Widget, provided by the TextExtension extension
-
lead(
) → Widget -
Available on Widget, provided by the TextExtension extension
-
li(
) → Widget -
Available on Widget, provided by the TextExtension extension
-
light(
) → Widget -
Available on Widget, provided by the TextExtension extension
-
medium(
) → Widget -
Available on Widget, provided by the TextExtension extension
-
mono(
) → Widget -
Available on Widget, provided by the TextExtension extension
-
muted(
) → Widget -
Available on Widget, provided by the TextExtension extension
-
normal(
) → Widget -
Available on Widget, provided by the TextExtension extension
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
p(
{bool firstChild = false}) → Widget -
Available on Widget, provided by the TextExtension extension
-
positioned(
{Key? key, double? left, double? top, double? right, double? bottom}) → Widget -
Available on Widget, provided by the WidgetExtension extension
-
primaryForeground(
) → Widget -
Available on Widget, provided by the TextExtension extension
-
sans(
) → Widget -
Available on Widget, provided by the TextExtension extension
-
secondaryForeground(
) → Widget -
Available on Widget, provided by the TextExtension extension
-
semiBold(
) → Widget -
Available on Widget, provided by the TextExtension extension
-
singleLine(
) → Widget -
Available on Widget, provided by the TextExtension extension
-
sized(
{double? width, double? height}) → Widget -
Available on Widget, provided by the WidgetExtension extension
-
small(
) → Widget -
Available on Widget, provided by the TextExtension extension
-
textCenter(
) → Widget -
Available on Widget, provided by the TextExtension extension
-
textEnd(
) → Widget -
Available on Widget, provided by the TextExtension extension
-
textJustify(
) → Widget -
Available on Widget, provided by the TextExtension extension
-
textLarge(
) → Widget -
Available on Widget, provided by the TextExtension extension
-
textLeft(
) → Widget -
Available on Widget, provided by the TextExtension extension
-
textMuted(
) → Widget -
Available on Widget, provided by the TextExtension extension
-
textRight(
) → Widget -
Available on Widget, provided by the TextExtension extension
-
textSmall(
) → Widget -
Available on Widget, provided by the TextExtension extension
-
textStart(
) → Widget -
Available on Widget, provided by the TextExtension extension
-
then(
InlineSpan span) → Widget -
Available on Widget, provided by the TextExtension extension
-
thenButton(
{required VoidCallback onPressed, required Widget child}) → Widget -
Available on Widget, provided by the TextExtension extension
-
thenInlineCode(
String text) → Widget -
Available on Widget, provided by the TextExtension extension
-
thenText(
String text) → Widget -
Available on Widget, provided by the TextExtension extension
-
thin(
) → Widget -
Available on Widget, provided by the TextExtension extension
-
toDiagnosticsNode(
{String? name, DiagnosticsTreeStyle? style}) → DiagnosticsNode -
Returns a debug representation of the object that is used by debugging
tools and by DiagnosticsNode.toStringDeep.
inherited
-
toString(
{DiagnosticLevel minLevel = DiagnosticLevel.info}) → String -
A string representation of this object.
inherited
-
toStringDeep(
{String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) → String -
Returns a string representation of this node and its descendants.
inherited
-
toStringShallow(
{String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) → String -
Returns a one-line detailed description of the object.
inherited
-
toStringShort(
) → String -
A short, textual description of this widget.
inherited
-
transform(
{Key? key, required Matrix4 transform}) → Widget -
Available on Widget, provided by the WidgetExtension extension
-
underline(
) → Widget -
Available on Widget, provided by the TextExtension extension
-
withAlign(
AlignmentGeometry alignment) → Widget -
Available on Widget, provided by the WidgetExtension extension
-
withMargin(
{double? top, double? bottom, double? left, double? right, double? horizontal, double? vertical, double? all}) → Widget -
Available on Widget, provided by the WidgetExtension extension
-
withOpacity(
double opacity) → Widget -
Available on Widget, provided by the WidgetExtension extension
-
withPadding(
{double? top, double? bottom, double? left, double? right, double? horizontal, double? vertical, double? all, EdgeInsetsGeometry? padding}) → Widget -
Available on Widget, provided by the WidgetExtension extension
-
x2Large(
) → Widget -
Available on Widget, provided by the TextExtension extension
-
x3Large(
) → Widget -
Available on Widget, provided by the TextExtension extension
-
x4Large(
) → Widget -
Available on Widget, provided by the TextExtension extension
-
x5Large(
) → Widget -
Available on Widget, provided by the TextExtension extension
-
x6Large(
) → Widget -
Available on Widget, provided by the TextExtension extension
-
x7Large(
) → Widget -
Available on Widget, provided by the TextExtension extension
-
x8Large(
) → Widget -
Available on Widget, provided by the TextExtension extension
-
x9Large(
) → Widget -
Available on Widget, provided by the TextExtension extension
-
xLarge(
) → Widget -
Available on Widget, provided by the TextExtension extension
-
xSmall(
) → Widget -
Available on Widget, provided by the TextExtension extension
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited