![]() |
VOOZH | about |
In Flutter a container is a simple widget with well-defined properties like height, width, and color, etc. The AnimatedContainer widget is a simple container widget with animations. These types of widgets can be animated by altering the values of their properties which are the same as the Container widget. These types of animation in Flutter is known as 'Implicit Animation. We will discuss then in detail in this article by building a simple app with AnimatedContainer widget.
Constructor of AnimatedContainer class:
AnimatedContainer(
{Key key,
AlignmentGeometry alignment,
EdgeInsetsGeometry padding,
Color color,
Decoration decoration,
Decoration foregroundDecoration,
double width,
double height,
BoxConstraints constraints,
EdgeInsetsGeometry margin,
Matrix4 transform,
Widget child,
Curve curve: Curves.linear,
@required Duration duration,
VoidCallback onEnd}
)
Properties of AnimatedContainer Widget:
Follow the below steps to build an application with AnimatedContainer widget:
Let's discuss them in detail.
Use the custom State class to create a StatefulWidget and define its properties as shown below:
Add an AnimatedContainer widget with its duration property defined that determines how long the container is going to animate as shown below:
Rebuilding and changing the properties after the end of duration specified property is done as shown below:
Complete Source Code:
Output: