removeChildAt method

  1. @override
void removeChildAt(
  1. int index
)
override

Remove the child at the specified index from the child list.

Implementation

@override
void removeChildAt(int index) {
  final RenderBox? child = this[index];

  // if child is null, it means this element was cached - drop the cached element
  if (child == null) {
    RenderBox? cachedChild = _keepAliveBucket[index];
    if (cachedChild != null) {
      dropChild(cachedChild);
      _keepAliveBucket.remove(index);
    }
    return;
  }

  final SliverVariableSizeBoxAdaptorParentData childParentData =
      child.parentData as SliverVariableSizeBoxAdaptorParentData;
  if (!childParentData._keptAlive) {
    super.removeChildAt(index);
    return;
  }
  assert(_keepAliveBucket[childParentData.index] == child);
  _keepAliveBucket.remove(childParentData.index);
  dropChild(child);
}