append method

void append (Layer child)

Adds the given layer to the end of this layer's child list.

Implementation

void append(Layer child) {
  assert(child != this);
  assert(child != firstChild);
  assert(child != lastChild);
  assert(child.parent == null);
  assert(!child.attached);
  assert(child.nextSibling == null);
  assert(child.previousSibling == null);
  assert(() {
    Layer node = this;
    while (node.parent != null)
      node = node.parent;
    assert(node != child); // indicates we are about to create a cycle
    return true;
  }());
  adoptChild(child);
  child._previousSibling = lastChild;
  if (lastChild != null)
    lastChild._nextSibling = child;
  _lastChild = child;
  _firstChild ??= child;
  assert(child.attached == attached);
}