applyTransform method Null safety

void applyTransform(
  1. Layer? child,
  2. Matrix4 transform

Applies the transform that would be applied when compositing the given child to the given matrix.

Specifically, this should apply the transform that is applied to child's origin. When using applyTransform with a chain of layers, results will be unreliable unless the deepest layer in the chain collapses the layerOffset in addToScene to zero, meaning that it passes to its children, and bakes any incoming layerOffset into the SceneBuilder as (for instance) a transform (which is then also included in the transformation applied by applyTransform).

For example, if addToScene applies the layerOffset and then passes to the children, then it should be included in the transform applied here, whereas if addToScene just passes the layerOffset to the child, then it should not be included in the transform applied here.

This method is only valid immediately after addToScene has been called, before any of the properties have been changed.

The default implementation does nothing, since ContainerLayer, by default, composites its children at the origin of the ContainerLayer itself.

The child argument should generally not be null, since in principle a layer could transform each child independently. However, certain layers may explicitly allow null as a value, for example if they know that they transform all their children identically.

The transform argument must not be null.

Used by FollowerLayer to transform its child to a LeaderLayer's position.


void applyTransform(Layer? child, Matrix4 transform) {
  assert(child != null);
  assert(transform != null);