Properties
| Property | Type | Description |
|---|---|---|
filter | Map<String, dynamic> | The image filter to apply to the existing painted content before painting the child. |
child | Map<String, dynamic>? | The widget to paint after applying the filter to the existing painted content. |
enabled | bool | Whether the filter should be applied. When false, the child is drawn without a filter. Defaults to true. |
blendMode | String? | The blend mode to apply when blending the filter with the existing content. Defaults to BlendMode.srcOver. Refer to BlendMode for available values. |
Filter Types
Thefilter property accepts different types of image filters. Here are the supported filter types:
Blur Filter
| Property | Type | Description |
|---|---|---|
type | String | Must be set to "blur". |
sigmaX | double | The standard deviation in the horizontal direction. Defaults to 10.0. |
sigmaY | double | The standard deviation in the vertical direction. Defaults to same as sigmaX. |
Dilate Filter
| Property | Type | Description |
|---|---|---|
type | String | Must be set to "dilate". |
radiusX | double | The radius in the horizontal direction. |
radiusY | double | The radius in the vertical direction. |
Erode Filter
| Property | Type | Description |
|---|---|---|
type | String | Must be set to "erode". |
radiusX | double | The radius in the horizontal direction. |
radiusY | double | The radius in the vertical direction. |
Compose Filter
| Property | Type | Description |
|---|---|---|
type | String | Must be set to "compose". |
inner | Map<String, dynamic> | The inner filter to apply first. |
outer | Map<String, dynamic> | The outer filter to apply after the inner filter. |
Usage Recommendations
For best results with BackdropFilter:- Use a
Stackto position the BackdropFilter over content you want to filter - Wrap the BackdropFilter in a
ClipRRectto constrain the filter to a specific area - Include a semi-transparent container as the child of the BackdropFilter to make the effect visible
- Use
fit: expandon the Stack to ensure proper sizing
Example JSON
Example 1: Frosted Glass Effect
Example 2: Dilate Filter Effect
Example 3: Compose Filter (Blur + Dilate)
Common Issues and Solutions
Issue: Filter affects entire screen
If your backdrop filter is affecting the entire screen instead of just a specific area, make sure to:- Wrap the BackdropFilter in a
ClipRRectto constrain its effects - Use a
Stackwith the BackdropFilter as a child positioned over the content to filter - Make sure the BackdropFilter is not at the root level of your widget tree
Issue: Filter not visible
If your filter effect isn’t visible:- Ensure the child of the BackdropFilter has a semi-transparent color (e.g.,
#80FFFFFF) - Check that the filter parameters (like
sigmaXandsigmaYfor blur) are large enough to be noticeable - Verify that the content behind the filter has sufficient contrast to make the effect visible