performRebuild method
- @override
override
Called by rebuild() after the appropriate checks have been made.
Implementation
@override
void performRebuild() {
_childWidgets.clear(); // Reset the cache, as described above.
super.performRebuild();
_currentBeforeChild = null;
assert(_currentlyUpdatingChildIndex == null);
try {
void processElement(int index) {
_currentlyUpdatingChildIndex = index;
final Element newChild = updateChild(_childElements[index], _build(index), index);
if (newChild != null) {
_childElements[index] = newChild;
final SliverMultiBoxAdaptorParentData parentData = newChild.renderObject.parentData;
if (!parentData.keptAlive)
_currentBeforeChild = newChild.renderObject;
} else {
_childElements.remove(index);
}
}
// processElement may modify the Map - need to do a .toList() here.
_childElements.keys.toList().forEach(processElement);
if (_didUnderflow) {
final int lastKey = _childElements.lastKey() ?? -1;
processElement(lastKey + 1);
}
} finally {
_currentlyUpdatingChildIndex = null;
}
}