VariableBlur class

A widget that applies variable blur effects to its child widget.

VariableBlur enables you to create sophisticated blur effects with different intensities for different regions of the widget. It's perfect for creating tilt-shift photography effects, focus transitions, or artistic blur overlays.

The widget uses GPU-accelerated Fragment Shaders for high-performance rendering and supports customizable blur regions, quality settings, and smooth edge transitions.

Key Features

  • Variable blur intensity across different regions
  • Smooth edge transitions with customizable intensity
  • High-performance GPU-accelerated rendering
  • Quality control for performance optimization
  • Android device compatibility support

Important Compatibility Note

Blur effects only work on images or colored containers. The child widget must have visible content (pixels) for the blur effect to be applied. Transparent widgets, empty containers, or widgets without background colors will not show blur effects.

Supported child widgets include:

  • Image widgets (network, asset, file, memory)
  • Container with background color or decoration
  • Widgets with colored backgrounds
  • Custom painted widgets with visible content

For comprehensive usage examples, please refer to the example app.

Example Usage

// Using normalized blur values (0.0 to 1.0)
VariableBlur(
  sigma: 15.0,
  blurSides: BlurSides.vertical(top: 1.0, bottom: 0.3),
  edgeIntensity: 0.2,
  quality: BlurQuality.high,
  useRepaintBoundary: true, // For performance optimization
  child: Image.asset('assets/photo.jpg'),
)

// Using pixel-based blur values with ResponsiveBlurSides
VariableBlur(
  sigma: 15.0,
  blurSides: ResponsiveBlurSides(top: 100.0, bottom: 50.0), // pixels
  edgeIntensity: 0.2,
  quality: BlurQuality.high,
  child: Image.asset('assets/photo.jpg'),
)

Performance Considerations

  • Use BlurQuality.low or BlurQuality.medium for better performance on lower-end devices
  • Higher sigma values require more processing power and automatically use larger kernel sizes
  • The edgeIntensity affects the smoothness of blur transitions
  • Quality settings automatically adjust kernel size for optimal performance
  • RepaintBoundary is enabled by default to isolate expensive blur operations
  • Set useRepaintBoundary to false only if you need manual RepaintBoundary management
Inheritance

Constructors

VariableBlur({Key? key, required Widget child, required double sigma, required BlurSidesBase blurSides, BlurQuality quality = BlurQuality.high, double edgeIntensity = 0.15, bool isYFlipNeed = false, bool useRepaintBoundary = true})
Creates a VariableBlur widget.
const

Properties

blurSides → BlurSidesBase
Defines the blur intensity for different regions of the widget.
final
child Widget
The widget to apply the blur effect to.
final
edgeIntensity double
Controls the intensity of smooth edge transitions (0.0 to 1.0).
final
hashCode int
The hash code for this object.
no setterinherited
isYFlipNeed bool
Whether to flip the Y-axis coordinate system.
final
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
quality BlurQuality
Controls the rendering quality vs performance trade-off.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
sigma double
The blur intensity/radius in logical pixels.
final
useRepaintBoundary bool
Whether to wrap the blur widget with RepaintBoundary for performance optimization.
final

Methods

build(BuildContext context) Widget
Describes the part of the user interface represented by this widget.
override
createElement() StatelessElement
Creates a StatelessElement to manage this widget's location in the tree.
inherited
debugDescribeChildren() List<DiagnosticsNode>
Returns a list of DiagnosticsNode objects describing this node's children.
inherited
debugFillProperties(DiagnosticPropertiesBuilder properties) → void
Add additional properties associated with the node.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toDiagnosticsNode({String? name, DiagnosticsTreeStyle? style}) DiagnosticsNode
Returns a debug representation of the object that is used by debugging tools and by DiagnosticsNode.toStringDeep.
inherited
toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) String
A string representation of this object.
inherited
toStringDeep({String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) String
Returns a string representation of this node and its descendants.
inherited
toStringShallow({String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) String
Returns a one-line detailed description of the object.
inherited
toStringShort() String
A short, textual description of this widget.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited