addToScene method Null safety

  1. @override
void addToScene(
  1. SceneBuilder builder,
  2. [Offset layerOffset = Offset.zero]
)
override

Override this method to upload this layer to the engine.

Return the engine layer for retained rendering. When there's no corresponding engine layer, null is returned.

Implementation

@override
void addToScene(ui.SceneBuilder builder, [ Offset layerOffset = Offset.zero ]) {
  assert(clipRRect != null);
  assert(clipBehavior != null);
  bool enabled = true;
  assert(() {
    enabled = !debugDisableClipLayers;
    return true;
  }());
  if (enabled) {
    final RRect shiftedClipRRect = layerOffset == Offset.zero ? clipRRect! : clipRRect!.shift(layerOffset);
    engineLayer = builder.pushClipRRect(
      shiftedClipRRect,
      clipBehavior: clipBehavior,
      oldLayer: _engineLayer as ui.ClipRRectEngineLayer?,
    );
  } else {
    engineLayer = null;
  }
  addChildrenToScene(builder, layerOffset);
  if (enabled)
    builder.pop();
}