Last active
July 14, 2018 19:07
-
-
Save salihgueler/17cce26a72be530769df0db06196c785 to your computer and use it in GitHub Desktop.
Easing Animation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class EasingAnimationWidget extends StatefulWidget { | |
@override | |
EasingAnimationWidgetState createState() => EasingAnimationWidgetState(); | |
} | |
class EasingAnimationWidgetState extends State<EasingAnimationWidget> | |
with TickerProviderStateMixin { | |
AnimationController _controller; | |
Animation _animation; | |
@override | |
void initState() { | |
super.initState(); | |
_controller = | |
AnimationController(vsync: this, duration: Duration(seconds: 2)); | |
_animation = Tween(begin: -1.0, end: 0.0).animate(CurvedAnimation( | |
parent: _controller, | |
curve: Curves.fastOutSlowIn, | |
)); | |
} | |
@override | |
Widget build(BuildContext context) { | |
final double width = MediaQuery.of(context).size.width; | |
return AnimatedBuilder( | |
animation: _controller, | |
builder: (BuildContext context, Widget child) { | |
return Scaffold( | |
body: Transform( | |
transform: | |
Matrix4.translationValues(_animation.value * width, 0.0, 0.0), | |
child: new Center( | |
child: Container( | |
width: 200.0, | |
height: 200.0, | |
color: Colors.black12, | |
)), | |
)); | |
}); | |
} | |
@override | |
void dispose() { | |
_controller.dispose(); | |
super.dispose(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment