Need help in basic way to implement of Animation in Flutter, basic Rotate,Fade-In,Scale,Translate animations. How to work on it, and apply combination of these animation. Flutter docs didn't help, unable to find any resource. Need basics way to do as explained here for Android XML https://www.androidhive.info/2013/06/android-working-with-xml-animations/
1 Answer
This is the simplest example of animation in Flutter.
class Home extends StatefulWidget {
@override
HomeState createState() {
return new HomeState();
}
}
class HomeState extends State<Home> with TickerProviderStateMixin {
AnimationController controller;
@override
void initState() {
super.initState();
controller = new AnimationController(
vsync: this, duration: new Duration(milliseconds: 2000));
}
@override
Widget build(BuildContext context) {
return new Scaffold(
body: new Center(
child: new Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
new RotationTransition(
turns: new Tween(begin: 0.0, end: 1.0).animate(controller),
child: new Container(
width: 150.0,
height: 150.0,
color: Colors.blue,
),
),
new MaterialButton(
child: new Text('Start Animation'),
onPressed: () {
setState(() {
controller.forward().then((_) {
controller.reverse();
});
});
},
)
],
),
),
);
}
}
All I have used is RotationTransition and AnimationController