detach method
void
detach()
Detaches this node from its parent in the scene graph.
Once detached, this node is removed from its parent's list of children, effectively disconnecting this node and its subtree (all child nodes) from the scene graph. This operation is useful for temporarily removing nodes from the scene without deleting them.
Throws an exception if this is the root node of the scene graph. No action is taken if the node already has no parent.
Implementation
void detach() {
if (_isSceneRoot) {
throw Exception('Root node cannot be detached');
}
final parent = _parent;
if (parent != null) {
parent.remove(this);
}
}