Skip to content

Instantly share code, notes, and snippets.

@salihgueler
Last active July 14, 2018 19:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save salihgueler/17cce26a72be530769df0db06196c785 to your computer and use it in GitHub Desktop.
Save salihgueler/17cce26a72be530769df0db06196c785 to your computer and use it in GitHub Desktop.
Easing Animation
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