Skip to content

Instantly share code, notes, and snippets.

@efortuna
Last active August 3, 2022 07:35
Show Gist options
  • Select an option

  • Save efortuna/af79b41b714d00b8f6081ca059b511d3 to your computer and use it in GitHub Desktop.

Select an option

Save efortuna/af79b41b714d00b8f6081ca059b511d3 to your computer and use it in GitHub Desktop.
class ColorAnimationWithStaticFinal extends StatelessWidget {
static final colorTween = ColorTween(begin: Colors.white, end: Colors.red);
@override
Widget build(BuildContext context) {
return Stack(
children: <Widget>[
starsBackground,
Center(
child: TweenAnimationBuilder<Color>(
tween: colorTween,
duration: Duration(seconds: 2),
builder: (_, Color color, __) {
return ColorFiltered(
child: Image.asset('assets/sun.png'),
colorFilter: ColorFilter.mode(color, BlendMode.modulate),
);
},
),
),
],
);
}
}
@danielmsd1
Copy link

Maybe we can consider changing line 2 to ;
static final colorTween = Tween<Color>(begin: Colors.white, end: Colors.red);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment