Skip to content

Instantly share code, notes, and snippets.

@felixblaschke
Created April 14, 2019 05:33
Show Gist options
  • Save felixblaschke/99f4eed7b07d72e5818d5e8a366f7513 to your computer and use it in GitHub Desktop.
Save felixblaschke/99f4eed7b07d72e5818d5e8a366f7513 to your computer and use it in GitHub Desktop.
Animated Background Gradient Widget
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