Created
July 14, 2018 21:39
-
-
Save salihgueler/f3dc553e64c3d348696d341eff04ae4d to your computer and use it in GitHub Desktop.
Value Change
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 ValueChangeAnimationWidget extends StatefulWidget { | |
@override | |
ValueChangeAnimationWidgetState createState() => | |
ValueChangeAnimationWidgetState(); | |
} | |
class ValueChangeAnimationWidgetState | |
extends State<ValueChangeAnimationWidget> with TickerProviderStateMixin { | |
AnimationController controller; | |
Animation animation; | |
@override | |
void initState() { | |
super.initState(); | |
controller = AnimationController( | |
duration: const Duration(milliseconds: 1000), vsync: this); | |
final Animation curve = | |
CurvedAnimation(parent: controller, curve: Curves.easeOut); | |
animation = IntTween(begin: 0, end: 10).animate(curve) | |
..addStatusListener((status) { | |
if (status == AnimationStatus.completed) { | |
controller.reverse(); | |
} | |
if (status == AnimationStatus.dismissed) { | |
Navigator.pop(context); | |
} | |
}); | |
} | |
@override | |
Widget build(BuildContext context) { | |
controller.forward(); | |
return AnimatedBuilder( | |
animation: controller, | |
builder: (BuildContext context, Widget child) { | |
return Scaffold( | |
body: new Center( | |
child: Text(animation.value.toString(), style: TextStyle(fontSize: 48.0)), | |
)); | |
}); | |
} | |
@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