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

Blend further paiting 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 causes them to use composited clips, for example.

Source

void pushOpacity(Offset offset, int alpha, PaintingContextCallback painter) {
  _stopRecordingIfNeeded();
  final OpacityLayer opacityLayer = new OpacityLayer(alpha: alpha);
  _appendLayer(opacityLayer);
  final PaintingContext childContext = new PaintingContext._(opacityLayer, _paintBounds);
  painter(childContext, offset);
  childContext._stopRecordingIfNeeded();
}