replaceRootLayer method Null safety

void replaceRootLayer(
  1. OffsetLayer rootLayer
)

Replace the layer. This is only valid for the root of a render object subtree (whatever object scheduleInitialPaint was called on).

This might be called if, e.g., the device pixel ratio changed.

Implementation

void replaceRootLayer(OffsetLayer rootLayer) {
  assert(!_debugDisposed);
  assert(rootLayer.attached);
  assert(attached);
  assert(parent is! RenderObject);
  assert(!owner!._debugDoingPaint);
  assert(isRepaintBoundary);
  assert(_layerHandle.layer != null); // use scheduleInitialPaint the first time
  _layerHandle.layer!.detach();
  _layerHandle.layer = rootLayer;
  markNeedsPaint();
}