pushBackdropFilter abstract method

BackdropFilterEngineLayer pushBackdropFilter(
  1. ImageFilter filter, {
  2. BlendMode blendMode = BlendMode.srcOver,
  3. BackdropFilterEngineLayer? oldLayer,
  4. int? backdropId,
})

Pushes a backdrop filter operation onto the operation stack.

The given filter is applied to the current contents of the scene as far back as the most recent save layer and rendered back to the scene using the indicated blendMode prior to rasterizing the child layers.

If backdropId is provided and not null, then this value is treated as a unique identifier for the backdrop. When the first backdrop filter with a given id is processed during rasterization, the state of the backdrop is recorded and cached. All subsequent backdrop filters with the same identifier will apply their filter to the cached backdrop. The correct usage of the backdrop id has the benefit of dramatically improving performance for applications with multiple backdrop filters. For example, an application that uses a backdrop blur filter for each item in a list view should set all filters to have the same backdrop id.

If overlapping backdrop filters use the same backdropId, then each filter will apply to the backdrop before the overlapping filter components were rendered.

If oldLayer is not null the engine will attempt to reuse the resources allocated for the old layer when rendering the new layer. This is purely an optimization. It has no effect on the correctness of rendering.

Passing a layer to addRetained or as oldLayer argument to a push method counts as usage. A layer can be used no more than once in a scene. For example, it may not be passed simultaneously to two push methods, or to a push method and to addRetained.

When a layer is passed to addRetained all descendant layers are also considered as used in this scene. The same single-usage restriction applies to descendants.

When a layer is passed as an oldLayer argument to a push method, it may no longer be used in subsequent frames. If you would like to continue reusing the resources associated with the layer, store the layer object returned by the push method and use that in the next frame instead of the original object.

See pop for details about the operation stack.

Implementation

BackdropFilterEngineLayer pushBackdropFilter(
  ImageFilter filter, {
  BlendMode blendMode = BlendMode.srcOver,
  BackdropFilterEngineLayer? oldLayer,
  int? backdropId,
});