removeChild method Null safety
- RenderBox child
override
Remove the given child from the child list.
Called by RenderSliverMultiBoxAdaptor.collectGarbage, which itself is
called from RenderSliverMultiBoxAdaptor's performLayout
.
The index of the given child can be obtained using the RenderSliverMultiBoxAdaptor.indexOf method, which reads it from the SliverMultiBoxAdaptorParentData.index field of the child's RenderObject.parentData.
Implementation
@override
void removeChild(RenderBox child) {
final int index = renderObject.indexOf(child);
assert(_currentlyUpdatingChildIndex == null);
assert(index >= 0);
owner!.buildScope(this, () {
assert(_childElements.containsKey(index));
try {
_currentlyUpdatingChildIndex = index;
final Element? result = updateChild(_childElements[index], null, index);
assert(result == null);
} finally {
_currentlyUpdatingChildIndex = null;
}
_childElements.remove(index);
assert(!_childElements.containsKey(index));
});
}