applyBounds method

Paint applyBounds(
  1. Rect bounds,
  2. AffineMatrix transform
)

Apply the bounds to the given paint.

May be a no-op if no properties of the paint are impacted by the bounds.

Implementation

Paint applyBounds(Rect bounds, AffineMatrix transform) {
  final Gradient? shader = fill?.shader;
  if (shader == null) {
    return this;
  }
  final Gradient newShader = shader.applyBounds(bounds, transform);
  return Paint(
    blendMode: blendMode,
    stroke: stroke,
    fill: Fill(
      color: fill!.color,
      shader: newShader,
    ),
  );
}