Created
May 2, 2020 12:53
-
-
Save felixblaschke/dc155718c7987538b169707ef587cd6e to your computer and use it in GitHub Desktop.
mt2.dart
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
// Create enum that defines the animated properties | |
enum AniProps { width, height, color } | |
class MyAnimatedWidget extends StatelessWidget { | |
// Specify your tween | |
final _tween = MultiTween<AniProps>() | |
..add(AniProps.width, 0.0.tweenTo(100.0), 1000.milliseconds) | |
..add(AniProps.width, 100.0.tweenTo(200.0), 500.milliseconds) | |
..add(AniProps.height, 0.0.tweenTo(200.0), 2500.milliseconds) | |
..add(AniProps.color, Colors.red.tweenTo(Colors.blue), 3.seconds); | |
@override | |
Widget build(BuildContext context) { | |
return PlayAnimation<MultiTweenValues<AniProps>>( | |
tween: _tween, // Pass in tween | |
duration: _tween.duration, // Obtain duration from MultiTween | |
builder: (context, child, value) { | |
return Container( | |
width: value.get(AniProps.width), // Get animated value for width | |
height: value.get(AniProps.height), // Get animated value for height | |
color: value.get(AniProps.color), // Get animated value for color | |
); | |
}, | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment