ImageFilter.blur constructor

ImageFilter.blur({
  1. double sigmaX = 0.0,
  2. double sigmaY = 0.0,
  3. TileMode? tileMode,
  4. Rect? bounds,
})

Creates an image filter that applies a Gaussian blur.

The sigma_x and sigma_y are the standard deviation of the Gaussian kernel in the X direction and the Y direction, respectively.

The tile_mode defines the behavior of sampling pixels at the edges when performing a standard, unbounded blur.

The bounds argument is optional and enables "bounded blur" mode. When bounds is non-null, the image filter substitutes transparent black for any sample it reads from outside the defined bounding rectangle. The final weighted sum is then divided by the total weight of the non-transparent samples (the effective alpha), resulting in opaque output.

The bounded mode prevents color bleeding from content adjacent to the bounds into the blurred area, and is typically used when the blur must be strictly contained within a clipped region, such as for iOS-style frosted glass effects.

The bounds rectangle is specified in the canvas's current coordinate space and is affected by the current transform; consequently, the bounds may not be axis-aligned in the final canvas coordinates.

Implementation

factory ImageFilter.blur({
  double sigmaX = 0.0,
  double sigmaY = 0.0,
  TileMode? tileMode,
  Rect? bounds,
}) {
  return _GaussianBlurImageFilter(
    sigmaX: sigmaX,
    sigmaY: sigmaY,
    tileMode: tileMode,
    bounds: bounds,
  );
}