addToScene method

  1. @override
void addToScene(
  1. SceneBuilder builder
)
override

Override this method to upload this layer to the engine.

Implementation

@override
void addToScene(ui.SceneBuilder builder) {
  assert(showWhenUnlinked != null);
  if (link.leader == null && !showWhenUnlinked!) {
    _lastTransform = null;
    _lastOffset = null;
    _inverseDirty = true;
    engineLayer = null;
    return;
  }
  _establishTransform();
  if (_lastTransform != null) {
    // NOTE MODIFIED this line is moved from below, such that it is run before addChildrenToScene
    _lastOffset = unlinkedOffset!;

    engineLayer = builder.pushTransform(
      _lastTransform!.storage,
      // NOTE MODIFIED [_engineLayer] to [engineLayer]
      oldLayer: engineLayer as ui.TransformEngineLayer?,
    );
    addChildrenToScene(builder);
    builder.pop();

    // NOTE MODIFIED move this line to above, such that it is run before addChildrenToScene
    // _lastOffset = unlinkedOffset!;
  } else {
    _lastOffset = null;
    final matrix =
        Matrix4.translationValues(unlinkedOffset!.dx, unlinkedOffset!.dy, 0);
    engineLayer = builder.pushTransform(
      matrix.storage,
      oldLayer: engineLayer as ui.TransformEngineLayer?,
    );
    addChildrenToScene(builder);
    builder.pop();
  }
  _inverseDirty = true;
}