pushOpacity method

void pushOpacity (Offset offset, int alpha, PaintingContextCallback painter)

Blend further painting with an alpha value.

  • offset is the offset from the origin of the canvas' coordinate system to the origin of the caller's coordinate system.
  • alpha is the alpha value to use when blending the painting done by painter. An alpha value of 0 means the painting is fully transparent and an alpha value of 255 means the painting is fully opaque.
  • painter is a callback that will paint with the alpha applied. This function calls the painter synchronously.

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

void pushOpacity(Offset offset, int alpha, PaintingContextCallback painter) {
  pushLayer(OpacityLayer(alpha: alpha, offset: offset), painter, Offset.zero);
}