Created
March 17, 2020 02:02
-
-
Save digitaljoni/1ad947b17f1898f19db74546485674e0 to your computer and use it in GitHub Desktop.
Gradient Icon Widget
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
| class GradientIcon extends StatelessWidget { | |
| GradientIcon( | |
| this.icon, | |
| this.size, | |
| this.gradient, | |
| ); | |
| final IconData icon; | |
| final double size; | |
| final Gradient gradient; | |
| @override | |
| Widget build(BuildContext context) { | |
| return ShaderMask( | |
| child: SizedBox( | |
| width: size * 1.2, | |
| height: size * 1.2, | |
| child: Icon( | |
| icon, | |
| size: size, | |
| color: Colors.white, | |
| ), | |
| ), | |
| shaderCallback: (Rect bounds) { | |
| final Rect rect = Rect.fromLTRB(0, 0, size, size); | |
| return gradient.createShader(rect); | |
| }, | |
| ); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Great widget. Thank you ❤️