replaceChildAt method

  1. @override
void replaceChildAt(
  1. Bitmap child,
  2. int index
)
override

Implementation

@override
void replaceChildAt(Bitmap child, int index) {
  if (index < 0 || index >= _children.length) {
    throw ArgumentError('The supplied index is out of bounds.');
  } else if (child.parent == this) {
    if (_children.indexOf(child) == index) return;
    throw ArgumentError('The bitmap is already a child of this container.');
  } else {
    final oldChild = _children[index];
    final newChild = child;
    newChild.removeFromParent();
    oldChild._parent = null;
    newChild._parent = this;
    _children[index] = newChild;
  }
}