swapChildren method

void swapChildren(
  1. DisplayObject child1,
  2. DisplayObject child2
)

Swaps the z-order (front-to-back order) of the two specified child objects.

All other child objects in the display object container remain in the same index positions.

Implementation

void swapChildren(DisplayObject child1, DisplayObject child2) {
  final index1 = getChildIndex(child1);
  final index2 = getChildIndex(child2);
  if (index1 == -1 || index2 == -1) {
    throw ArgumentError(
        'The supplied DisplayObject must be a child of the caller.');
  } else {
    swapChildrenAt(index1, index2);
  }
}