Created
April 14, 2019 05:33
-
-
Save felixblaschke/99f4eed7b07d72e5818d5e8a366f7513 to your computer and use it in GitHub Desktop.
Animated Background Gradient Widget
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 AnimatedBackground extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
final tween = MultiTrackTween([ | |
Track("color1").add(Duration(seconds: 3), | |
ColorTween(begin: Color(0xffD38312), end: Colors.lightBlue.shade900)), | |
Track("color2").add(Duration(seconds: 3), | |
ColorTween(begin: Color(0xffA83279), end: Colors.blue.shade600)) | |
]); | |
return ControlledAnimation( | |
playback: Playback.MIRROR, | |
tween: tween, | |
duration: tween.duration, | |
builder: (context, animation) { | |
return Container( | |
decoration: BoxDecoration( | |
gradient: LinearGradient( | |
begin: Alignment.topCenter, | |
end: Alignment.bottomCenter, | |
colors: [animation["color1"], animation["color2"]])), | |
); | |
}, | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment