Composing Animations and Chaining Animations in Dart's Flutter Framework

What Will I Learn?

  • You will learn how to use custom tween animations with custom values
  • You will learn how to chain and compose animations in flutter
  • You will learn how to use an Animated Builder widget

Requirements

Difficulty

  • Intermediate

Description

In this flutter video tutorial, we take a look at how we can create longer more complex animations by chaining and composing different animations together. We can use these various animations and apply them to a single widget to give it multiple dynamic features. Specifically, we look at how we can build out a box animation that first fades in using the opacity widget and property. Next the box rotates around the z axis using the transform property. Then the box moves upwards and to the right which is accomplished by manipulating the margin and edge insets of the box. The box then scales upwards and becomes a larger box before changing from a square into a circle. During this animation, the box also changes colors from red to a deep purple color. At the end of the tutorial, we change the intervals of each of these animations so that they overlap with one another.

We make use of the animated builder widget; a widget that allows us to build out a widget or set of widgets that use animations as a smaller part of the tree. This widget allows us to create a subtree of widgets which is more efficient because we do not need to re-render the entire widget tree every frame. We also make use of some of the custom made tween widgets in the flutter framework; these include the color tween, the edge insets tween and the border radius tween. These tweens automatically take the output of our curve functions and convert it to the proper property that we need for our animation elements.

The source code for this project can be found here

Video Tutorial

Curriculum



Posted on Utopian.io - Rewarding Open Source Contributors

H2
H3
H4
3 columns
2 columns
1 column
5 Comments