updateLayerProperties static method Null safety

void updateLayerProperties(
  1. RenderObject child
)

Update the composited layer of child without repainting its children.

The render object must be attached to a PipelineOwner, must have a composited layer, and must be in need of a composited layer update but not in need of painting. The render object's layer is re-used, and none of its children are repaint or their layers updated.

See also:

Implementation

static void updateLayerProperties(RenderObject child) {
  assert(child.isRepaintBoundary && child._wasRepaintBoundary);
  assert(!child._needsPaint);
  assert(child._layerHandle.layer != null);

  final OffsetLayer childLayer = child._layerHandle.layer! as OffsetLayer;
  Offset? debugOldOffset;
  assert(() {
    debugOldOffset = childLayer.offset;
    return true;
  }());
  final OffsetLayer updatedLayer = child.updateCompositedLayer(oldLayer: childLayer);
  assert(identical(updatedLayer, childLayer),
    '$child created a new layer instance $updatedLayer instead of reusing the '
    'existing layer $childLayer. See the documentation of RenderObject.updateCompositedLayer '
    'for more information on how to correctly implement this method.'
  );
  assert(debugOldOffset == updatedLayer.offset);
  child._needsCompositedLayerUpdate = false;
}