pushPhysicalShape method Null safety

PhysicalShapeEngineLayer pushPhysicalShape(
  1. {required Path path,
  2. required double elevation,
  3. required Color color,
  4. Color? shadowColor,
  5. Clip clipBehavior = Clip.none,
  6. PhysicalShapeEngineLayer? oldLayer}
)

Pushes a physical layer operation for an arbitrary shape onto the operation stack.

By default, the layer's content will not be clipped (clip = Clip.none). If clip equals Clip.hardEdge, Clip.antiAlias, or Clip.antiAliasWithSaveLayer, then the content is clipped to the given shape defined by path.

If elevation is greater than 0.0, then a shadow is drawn around the layer. shadowColor defines the color of the shadow if present and color defines the color of the layer background.

If oldLayer is not null the engine will attempt to reuse the resources allocated for the old layer when rendering the new layer. This is purely an optimization. It has no effect on the correctness of rendering.

Passing a layer to addRetained or as oldLayer argument to a push method counts as usage. A layer can be used no more than once in a scene. For example, it may not be passed simultaneously to two push methods, or to a push method and to addRetained.

When a layer is passed to addRetained all descendant layers are also considered as used in this scene. The same single-usage restriction applies to descendants.

When a layer is passed as an oldLayer argument to a push method, it may no longer be used in subsequent frames. If you would like to continue reusing the resources associated with the layer, store the layer object returned by the push method and use that in the next frame instead of the original object.

See pop for details about the operation stack, and Clip for different clip modes.

Implementation

PhysicalShapeEngineLayer pushPhysicalShape({
  required Path path,
  required double elevation,
  required Color color,
  Color? shadowColor,
  Clip clipBehavior = Clip.none,
  PhysicalShapeEngineLayer? oldLayer,
}) {
  assert(_debugCheckCanBeUsedAsOldLayer(oldLayer, 'pushPhysicalShape'));
  final EngineLayer engineLayer = EngineLayer._();
  _pushPhysicalShape(engineLayer, path, elevation, color.value, shadowColor?.value ?? 0xFF000000,
      clipBehavior.index, oldLayer?._nativeLayer);
  final PhysicalShapeEngineLayer layer = PhysicalShapeEngineLayer._(engineLayer);
  assert(_debugPushLayer(layer));
  return layer;
}