move method

void move(
  1. ChildType child, {
  2. ChildType? after,
})

Move the given child in the child list to be after another child.

More efficient than removing and re-adding the child. Requires the child to already be in the child list at some position. Pass null for after to move the child to the start of the child list.

Implementation

void move(ChildType child, { ChildType? after }) {
  assert(child != this);
  assert(after != this);
  assert(child != after);
  assert(child.parent == this);
  final ParentDataType childParentData = child.parentData! as ParentDataType;
  if (childParentData.previousSibling == after) {
    return;
  }
  _removeFromChildList(child);
  _insertIntoChildList(child, after: after);
  markNeedsLayout();
}