Flutter Animated Intervals

class Home extends StatefulWidget {
@override
_HomeState createState() => _HomeState();
}
class _HomeState extends State<Home> with SingleTickerProviderStateMixin {AnimationController _controller;@override
void initState() {
_controller =AnimationController(vsync: this, duration: const Duration(seconds: 2));super.initState();
}
}
@override
void dispose() {
_controller.dispose();
super.dispose();
}
@overrideWidget build(BuildContext context) {return Scaffold(body: Column(children: [Spacer(),Container(margin: EdgeInsets.all(10),width: double.infinity,height: 300,child: PlayGround(controller: _controller,),),Spacer(),Row(children: [RaisedButton(onPressed: () {_controller.forward();},child: Text("Forward"),),Spacer(),RaisedButton(onPressed: () {_controller.reverse();},child: Text("Reverse"),)],)],),);}
final Animation<double> animateWidth;final Animation<double> animateHeight;final Animation<EdgeInsets> animatePadding;final Animation<BorderRadius> animateRadius;final Animation<double> rotationAnimation;final Animation<Color> animateColor;
This is the way: animatePadding = EdgeInsetsTween(begin: EdgeInsets.all(0),end: EdgeInsets.only(top: 100.0, left: 10)).animate(CurvedAnimation(parent: controller,curve: Interval(0.2, 0.4, curve: Curves.fastOutSlowIn))),
  1. curve — This takes an Interval with a starting point, ending point, and a Curve which is the behaviour of animating.
  2. reverse curve— reverse behaviour of animating.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store