Skip to content

Instantly share code, notes, and snippets.

@erikwco
Last active May 16, 2019 17:14
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 erikwco/5dcf6f60334303f0ba47d848d0aff166 to your computer and use it in GitHub Desktop.
Save erikwco/5dcf6f60334303f0ba47d848d0aff166 to your computer and use it in GitHub Desktop.
Animation Definition for our button
// Defining Animations and Animation Controller
Animation<double> _animatedSize;
Animation<Color> _animatedColor;
AnimationController _boss;
// Initialize Animations and AnimationController
@override
void initState() {
super.initState();
// AnimationController
_boss = AnimationController(duration: Duration(milliseconds: 300), vsync: this);
// Animations
// size using Tween<double>
_animatedSize = Tween<double>(begin:0, end:300).animate(_boss)
..addListener((){
setState(() {});
});
// color using a subclass of Tween, ColorTween
_animatedColor = ColorTween(begin: Colors.yellow, end: Colors.red).animate(_boss);
}
// Never forget to dispose the AnimationController
// to avoid memory leaks
@override
void dispose() {
_boss.dispose();
super.dispose();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment