fromColor method
- Color color
override
Returns a copy of this gradient with all of its colors replaced by the
given color.
The geometry of the gradient (such as its stops and the
subclass-specific positioning) is preserved, so the result paints as a
uniform color. This is useful to represent a solid color as a gradient,
for example when interpolating between a color and a gradient with lerp.
Subclasses should override this method to preserve their own geometry. The base implementation returns a LinearGradient; this is sufficient because a gradient with uniform colors paints as a solid color regardless of its geometry.
Implementation
@override
SweepGradient fromColor(Color color) {
return SweepGradient(
center: center,
startAngle: startAngle,
endAngle: endAngle,
colors: List<Color>.filled(colors.length, color),
stops: stops,
tileMode: tileMode,
transform: transform,
);
}