createGradientPaint static method
Paint
createGradientPaint({
- required Gradient gradient,
- required Rect bounds,
- PaintingStyle style = PaintingStyle.fill,
- double? strokeWidth,
Creates a paint object with a gradient shader.
gradient is the gradient to use as the shader.
style is the painting style. Defaults to PaintingStyle.fill.
strokeWidth is the width of the stroke. Only used when style is PaintingStyle.stroke.
Implementation
static Paint createGradientPaint({
required Gradient gradient,
required Rect bounds,
PaintingStyle style = PaintingStyle.fill,
double? strokeWidth,
}) {
final paint = Paint()
..shader = gradient.createShader(bounds)
..style = style;
if (strokeWidth != null && style == PaintingStyle.stroke) {
paint.strokeWidth = strokeWidth;
}
return paint;
}