pushColorFilter method

ColorFilterLayer pushColorFilter (Offset offset, ColorFilter colorFilter, PaintingContextCallback painter, { ColorFilterLayer oldLayer })

Blend further painting with a color filter.

  • offset is the offset from the origin of the canvas' coordinate system to the origin of the caller's coordinate system.
  • colorFilter is the ColorFilter value to use when blending the painting done by painter.
  • painter is a callback that will paint with the colorFilter applied. This function calls the painter synchronously. null

A RenderObject that uses this function is very likely to require its RenderObject.alwaysNeedsCompositing property to return true. That informs ancestor render objects that this render object will include a composited layer, which, for example, causes them to use composited clips.

Implementation

ColorFilterLayer pushColorFilter(Offset offset, ColorFilter colorFilter, PaintingContextCallback painter, { ColorFilterLayer oldLayer }) {
  assert(colorFilter != null);
  final ColorFilterLayer layer = oldLayer ?? ColorFilterLayer();
  layer.colorFilter = colorFilter;
  pushLayer(layer, painter, offset);
  return layer;
}