markNeedsCompositedLayerUpdate method Null safety

void markNeedsCompositedLayerUpdate()

Mark this render object as having changed a property on its composited layer.

Render objects that have a composited layer have isRepaintBoundary equal to true may update the properties of that composited layer without repainting their children. If this render object is a repaint boundary but does not yet have a composited layer created for it, this method will instead mark the nearest repaint boundary parent as needing to be painted.

If this method is called on a render object that is not a repaint boundary or is a repaint boundary but hasn't been composited yet, it is equivalent to calling markNeedsPaint.

See also:

  • RenderOpacity, which uses this method when its opacity is updated to update the layer opacity without repainting children.

Implementation

void markNeedsCompositedLayerUpdate() {
  assert(!_debugDisposed);
  assert(owner == null || !owner!.debugDoingPaint);
  if (_needsCompositedLayerUpdate || _needsPaint) {
    return;
  }
  _needsCompositedLayerUpdate = true;
  // If this was not previously a repaint boundary it will not have
  // a layer we can paint from.
  if (isRepaintBoundary && _wasRepaintBoundary) {
    // If we always have our own layer, then we can just repaint
    // ourselves without involving any other nodes.
    assert(_layerHandle.layer != null);
    if (owner != null) {
      owner!._nodesNeedingPaint.add(this);
      owner!.requestVisualUpdate();
    }
  } else {
    markNeedsPaint();
  }
}