Reputation: 117
Hy everyone,
I need to know, how do I can create so a Gradient colors from topLeft to bottomRight withhin a shader in flutter like in this image example?
I tried with this mini shader code to do this, but it still doesn't working for me.
final Shader linearGradient = LinearGradient(
colors: gradientColors,
).createShader(
Rect.fromCircle(
center: Offset(fontSize, -200),
radius: fontSize / 3,
),
);
Could anybody have a ideea, how can this be created? Or it's not impossible right now in Flutter 🤷♂️
Upvotes: 0
Views: 4803
Reputation: 671
Container(decoration: BoxDecoration(
gradient: LinearGradient(
begin:Alignment.topLeft,
end:Alignment.bottomRight,
colors: [Colors.blue[800],
Colors.blue[200]
]),
),
)
Upvotes: 0
Reputation: 9625
Have you tried using the begin
and end
properties of LinearGradient
?
final Shader linearGradient = LinearGradient(
begin: Alignment.topLeft,
end: Alignment.bottomRight,
colors: gradientColors,
).createShader(
Rect.fromCircle(
center: Offset(fontSize, -200),
radius: fontSize / 3,
)
);
Upvotes: 3