setRoot method

void setRoot(
  1. RenderTree tree,
  2. String rootId
)

Implementation

void setRoot(RenderTree tree, String rootId) {
  if (identical(tree, _tree) && rootId == _rootId) return;
  final old = child;
  if (old is NodeBox) {
    child = null;
    old.tree.release(old);
  }
  _tree = tree;
  _rootId = rootId;
  final box = tree.obtain(rootId, tree.rootSlot(rootId));
  // Another view showed it (a view rebuilt elsewhere in the app): it's
  // this one's now.
  if (box.parent != null) box.detachFromParent();
  child = box;
}