moveChildToNewParent method

void moveChildToNewParent(
  1. Container<Node?>? newParent
)

Moves children of this node to newParent.

Implementation

void moveChildToNewParent(Container? newParent) {
  if (isEmpty) {
    return;
  }

  final last = newParent!.isEmpty ? null : newParent.last as T?;
  while (isNotEmpty) {
    final child = first as T;
    child?.unlink();
    newParent.add(child);
  }

  /// In case [newParent] already had children we need to make sure
  /// combined list is optimized.
  if (last != null) last.adjust();
}