mount method

  1. @mustCallSuper
void mount(
  1. Branch? parent,
  2. Object? slot
)

Attaches this branch into the tree under parent at slot.

Implementation

@mustCallSuper
void mount(Branch? parent, Object? slot) {
  assert(
    !_mounted,
    'mount() called on already-mounted branch (id=$branchId).',
  );
  _parent = parent;
  owner ??= parent?.owner;
  assert(
    owner != null,
    'mount() requires a non-null owner; call TreeOwner.mountRoot() '
    'for root branches, or mount under a parent that has an owner.',
  );
  branchId = owner!.issueId();
  _mounted = true;
  depth = (parent?.depth ?? -1) + 1;
}