Implicit Animation In Flutter

Updated 28 April 2023

Save

In this blog, we are going to learn about  Implicit Animation In Flutter.  We don’t need to write code for basic animation, we can achieve animation by changing some property values of widgets.

You may also check our interactive app designs by our Flutter app development company

Implicit Animation

Using implicit animations, you can animate a widget property by setting a target value. When we setState in StatefulWidget then new target values, like color, width, height, and, etc. changes with a specified duration from the old value to the new value.

Some  implicit animation Widgets:

1. AnimatedOpacity: We can hide and show widgets using opacity. Its value lies between 0 (no visibility) and 1 (visible).

2.AnimatedCrossFade: Replace one widget with another and animates itself between sizes.

3.AnimatedPositioned:  It is used to change the position of the widget to a new position with a specified duration,

4.AnimatedContainer: We can animate properties like width, height, background colors, etc. 

AnimatedContainer widget:

Let’s check implementations of AnimatedContainer

  1. Create a StatefulWidget  
  2. Declare properties with initial values _width = 50,  double _height = 50,  _color = Colors.green , _borderRadius = BorderRadius.circular(8)
  3. Add AnimatedContainer using the properties.
  4. Change the value of properties randomly on the click button and rebuild the widget with new properties.

Let’s check the final result of the code.

I hope this blog will help to add animation to your widgets.

Happy Learning 🙂

Reference Links :

https://flutter.dev/docs/cookbook/animation/animated-container

author
. . .

Leave a Comment

Your email address will not be published. Required fields are marked*


Be the first to comment.

Start a Project


    Message Sent!

    If you have more details or questions, you can reply to the received confirmation email.

    Back to Home