beginGradientFill method
Begins filling a shape with the specified gradient.
If _holeMode
is true, the method will do nothing and return this
Graphics object.
If ratios
is not specified, the method creates an equal distribution of
color across the gradient.
If begin
is not specified, the method uses Alignment.center.
If end
is not specified, the method uses Alignment.centerRight.
If rotation
is not specified, the method uses 0.0
.
If tileMode
is not specified, the method uses TileMode.clamp.
If gradientBox
is specified, the method uses it to create a gradient
shader that matches the bounding box of the object.
If radius
is not specified, the method uses 0.5
.
If focalRadius
is not specified, the method uses 0.0
.
If sweepStartAngle
is not specified, the method uses 0.0
.
If sweepEndAngle
is not specified, the method uses 6.2832
.
Returns this Graphics object after beginning the gradient fill. For
GradientType.radial, end
is used for RadialGradient.focal, check the
RadialGradient docs to understand the relation with focalRadius
Implementation
Graphics beginGradientFill(
GradientType type,
List<Color> colors, {
List<double>? ratios,
Alignment? begin,
Alignment? end,
double rotation = 0,
TileMode tileMode = TileMode.clamp,
Rect? gradientBox,
/// only radial
double radius = 0.5,
double focalRadius = 0.0,
/// only sweep
double sweepStartAngle = 0.0,
double sweepEndAngle = 6.2832,
}) {
final gradient = _createGradient(
type,
colors,
ratios,
begin,
end,
rotation,
radius,
focalRadius,
sweepStartAngle,
sweepEndAngle,
tileMode,
);
final paint = Paint();
paint.style = PaintingStyle.fill;
paint.isAntiAlias = true;
_addFill(paint);
if (gradientBox != null) {
_currentDrawing!.fill!.shader = gradient.createShader(gradientBox);
} else {
_currentDrawing!.gradient = gradient;
}
return this;
}