performRebuild method Null safety

  1. @override
void performRebuild()
override

Called by rebuild() after the appropriate checks have been made.

Implementation

@override
void performRebuild() {
  _childWidgets.clear();
  super.performRebuild();
  if (_childElements.isEmpty)
    return;

  final int firstIndex = _childElements.firstKey()!;
  final int lastIndex = _childElements.lastKey()!;

  for (int index = firstIndex; index <= lastIndex; ++index) {
    final Element? newChild = updateChild(_childElements[index], retrieveWidget(index), index);
    if (newChild != null) {
      _childElements[index] = newChild;
    } else {
      _childElements.remove(index);
    }
  }
}