addToScene method

  1. @override
void addToScene (SceneBuilder builder, [ 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(clipPath != null);
  assert(clipBehavior != null);
  assert(elevation != null);
  assert(color != null);
  assert(shadowColor != null);

  bool enabled = true;
  assert(() {
    enabled = !debugDisablePhysicalShapeLayers;
    return true;
  }());
  if (enabled) {
    engineLayer = builder.pushPhysicalShape(
      path: layerOffset == Offset.zero ? clipPath : clipPath.shift(layerOffset),
      elevation: elevation,
      color: color,
      shadowColor: shadowColor,
      clipBehavior: clipBehavior,
      oldLayer: _engineLayer,
    );
  } else {
    engineLayer = null;
  }
  addChildrenToScene(builder, layerOffset);
  if (enabled)
    builder.pop();
}