![]() |
VOOZH | about |
The animations are considered hard work and take time to learn. Flutter made it easy with its packages. To animate the widgets without much effort, we can wrap them inside different defined animated widgets in the animate_do package. In this article, we will see how with the animate_do package we can animate widgets easily and enhance the user experience.
Add the dependency
In the pubspec.yaml file, add animate_do dependency under dependencies section. Run pub get to install this dependency or hit Ctrl + S in windows do to so.
👁 Add the dependencyImport the dependency
In main.dart, import the dependency in the following way:
import 'package:animate_do/animate_do.dart';
Implementation
In the animate_do package, there are different animated widgets available that we can make use of. Some of them are -
The properties of all these animated widgets are the same. The properties are -
Before moving to the animated widgets, let's create a common widget that we will pass to each animated widget as a child. Here, we are creating a StatelessWidget NewContainer that returns a green color container.
Let's dive into examples of different animations now.
Bouncing Animation
The BounceIn animated widget involves the bouncing of the child widget. The bouncing widget can be bounced Down, Up, Left or right. To bounce down widget use BounceInDown, for Up use BounceInUp. Similarly for other directions.
Output:
Fading Animations
The FadeIn animated widget also involves fading animated widgets in four directions - Up, Down, Left, Right. In the below example, we are creating simple fading animations which fade in four different directions.
Output:
Sliding Animations
Sliding animations can also be done in four directions - Up, Right, Down, or Left. In the below example, we are creating left sliding animations only. We are delaying the animation of each animated widget to appear in a sequence on a screen. For better visualization, see the output.
Output:
Attention Seeker Animations
There are some more animated widgets available like swing, spin, dancing widget, etc. If we want the animation to be forever, we set the infinite property of the animated widget to true.
Output:
Complete Example Code
Output: