Flutter – Hinge Animation
Animations are a big part of the Flutter application. It makes an app sweet to the eyes and equally user-friendly. In this article, we will discuss in detail the Hinge animations. In Flutter there are two ways to work with animations namely:
- A pub package
- Animated Builder Widget
In this article, we will be working with the Animated Builder widget. A Hinge animation is a type of animation where an element can turn over with a sudden movement. To implement the same follow the below steps:
- Create a dart file (say, hinge_animation) inside the lib folder of the project.
- Add a FloatingActionButton to play the animation and a text to implement the animation inside the hinge_animation.dart file.
- Now create a tween with a CurvedAnimation using the _rotationAnimation property.
- Now use the Animation Controller to handle and create the instance of the animation.
Let’s explore these steps in detail.
The hinge_animation.dart file:
After adding the text, the FloatingActionButton, the AnimationController, and the curved animation the file would somewhat look like below:
The main.dart file:
This is the main structure of all flutter applications. After the above hinge_animation.dart file is completed we just need to import the same in the main.dart file as shown below: