Animate linear gradient on shader mask

0

Hi I'm using a linear gradient within a shader mask to apply a gradient to an Icon code below:

child: LinearGradientMask(
          colors: [Color(0xFF21A9E4), Color(0xFF6152E7)],
          child: Icon(
            Icons.power_settings_new,
            size: 90,
            color: Color(0xFFFFFFFF),
          ),
        )
class LinearGradientMask extends StatelessWidget {
  LinearGradientMask({this.child, this.colors});

  final Widget child;
  final List<Color> colors;

  @override
  Widget build(BuildContext context) {
    return ShaderMask(
      shaderCallback: (bounds) => LinearGradient(
        begin: FractionalOffset.topLeft,
        end: FractionalOffset.bottomRight,
        colors: colors,
        tileMode: TileMode.mirror,
      ).createShader(bounds),
      child: child,
    );
  }
}

I'm new to the animation builder and I want to be able to update the colours in a state variable and get the icon to animate the gradient as it is changed. The button looks like this:

Button image

flutter
flutter-animation
asked on Stack Overflow Feb 21, 2020 by Jack_b_321

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0