Reputation: 55
I trying to achive this type of gradient on icons but unable to do that...
Output image
I already use this code for that but it also dosen't show any effect
ShaderMask(
shaderCallback: (Rect bounds) => RadialGradient(
center: Alignment.center,
radius: 0.5,
colors: [
Colors.pink,
Colors.deepOrange,
],
tileMode: TileMode.mirror,
).createShader(bounds),
child: Icon(Icons.access_time,),),
What should I do for achiving that?
Upvotes: 3
Views: 5883
Reputation: 5223
final List<Color> gradientColors = [
Colors.blue,
Colors.purple,
Colors.orange
];
ShaderMask(
blendMode: BlendMode.srcIn,
shaderCallback: (Rect bounds) => LinearGradient(
begin: Alignment.topLeft,
end: Alignment.bottomRight,
colors: gradientColors, // Gradient colors for the icon
).createShader(bounds),
child: Icon(
Icons.message,
),
);
Upvotes: 1
Reputation: 63799
It is missing blendMode: BlendMode.srcIn
. Play with stops
and colors
ShaderMask(
blendMode: BlendMode.srcIn,
shaderCallback: (Rect bounds) => RadialGradient(
center: Alignment.topCenter,
stops: [.5, 1],
colors: [
Colors.pink,
Colors.yellow,
],
).createShader(bounds),
child: Icon(
Icons.access_time,
size: 133,
),
),
Upvotes: 13