swapChildrenAt method

void swapChildrenAt(
  1. int index1,
  2. int index2
)

Swaps the two children objects at the specified indexes.

The index positions of the two objects are passed in as parameters to this method. If the index positions are invalid (i.e. out of range) an error is thrown. Otherwise, the objects at the specified index positions are swapped. After the swap is completed, the parent display object is redrawn if it is part of the stage display list.

Implementation

void swapChildrenAt(int index1, int index2) {
  final child1 = getChildAt(index1);
  final child2 = getChildAt(index2);
  children[index1] = child2;
  children[index2] = child1;
  requiresRedraw();
}