addToScene method

  1. @override
EngineLayer 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
ui.EngineLayer addToScene(ui.SceneBuilder builder, [Offset layerOffset = Offset.zero]) {
  assert(link != null);
  assert(showWhenUnlinked != null);
  if (link.leader == null && !showWhenUnlinked) {
    _lastTransform = null;
    _lastOffset = null;
    _inverseDirty = true;
    return null; // this does not have an engine layer.
  }
  _establishTransform();
  if (_lastTransform != null) {
    builder.pushTransform(_lastTransform.storage);
    addChildrenToScene(builder);
    builder.pop();
    _lastOffset = unlinkedOffset + layerOffset;
  } else {
    _lastOffset = null;
    final Matrix4 matrix = Matrix4.translationValues(unlinkedOffset.dx, unlinkedOffset.dy, .0);
    builder.pushTransform(matrix.storage);
    addChildrenToScene(builder);
    builder.pop();
  }
  _inverseDirty = true;
  return null; // this does not have an engine layer.
}