This file contains hidden or 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
return MirrorAnimation<double>( // <-- changed to "MirrorAnimation" | |
duration: 800.milliseconds, | |
curve: Curves.easeInOut, | |
tween: 0.0.tweenTo(200.0), | |
builder: (context, child, value) { | |
return Container(width: value, height: value, color: Colors.green); | |
}, | |
); |
This file contains hidden or 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
return LoopAnimation<double>( // <-- changed to "LoopAnimation" | |
duration: 800.milliseconds, | |
curve: Curves.easeInOut, | |
tween: 0.0.tweenTo(200.0), | |
builder: (context, child, value) { | |
return Container(width: value, height: value, color: Colors.green); | |
}, | |
); |
This file contains hidden or 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
return PlayAnimation<double>( // <-- set animatino type | |
duration: 800.milliseconds, | |
curve: Curves.easeInOut, | |
tween: 0.0.tweenTo(200.0), // <-- double tween | |
builder: (context, child, value) { | |
return Container( // <-- return a Container | |
width: value, // <-- use animated value for width | |
height: value, // <-- use animated value for height | |
color: Colors.green, | |
); |
This file contains hidden or 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 MyWidget extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return PlayAnimation<int>( | |
duration: 5.seconds, // <-- set duration | |
curve: Curves.easeIn, // <-- apply non-linear curve | |
tween: 0.tweenTo(64736), | |
builder: (context, child, value) { | |
return Text("$value likes", style: TextStyle(fontSize: 30)); | |
}, |
This file contains hidden or 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 MyWidget extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return PlayAnimation<int>( | |
tween: 0.tweenTo(64736), // <-- set tween | |
builder: (context, child, value) { | |
return Text("$value likes", style: TextStyle(fontSize: 30)); | |
}, | |
); | |
} |
This file contains hidden or 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 MyWidget extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return PlayAnimation<int>( // <-- animate integers | |
builder: (context, child, value) { | |
return Text( | |
"$value likes", // <-- use animated value | |
style: TextStyle(fontSize: 30), | |
); | |
}, |
This file contains hidden or 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 MyWidget extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return PlayAnimation( | |
builder: (context, child, value) { | |
return Text("64736 likes", style: TextStyle(fontSize: 30),); | |
}, | |
); | |
} | |
} |
This file contains hidden or 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 MyWidget extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return Text("64736 likes", style: TextStyle(fontSize: 30),); | |
} | |
} |
This file contains hidden or 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
/* Supercharged supports your animations */ | |
// create numeric tweens | |
100.0.tweenTo(200.0); | |
// create color tweens | |
Colors.red.tweenTo(Colors.yellow); | |
// create durations | |
600.milliseconds; |
This file contains hidden or 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 _MyAnimatedWidgetState extends State<MyAnimatedWidget> | |
with AnimationMixin { // <-- add AnimationMixin to state class | |
Animation<double> size; // <-- declare animation variable | |
@override | |
void initState() { | |
// the mixin provides you with a ready to use AnimationController as "controller" variable | |
size = 0.0.tweenTo(200.0).animatedBy(controller); // <-- connect tween and controller and apply to animation variable | |
controller.play(); // <-- start the animation playback |