createChild method

  1. @override
void createChild(
  1. _PopUpList? popUpList,
  2. int index, {
  3. required RenderBox? after,
})
override

Implementation

@override
void createChild(_PopUpList? popUpList, int index,
    {required RenderBox? after}) {
  assert(_currentlyUpdatingChildIndex == null);
  owner!.buildScope(this, () {
    final childElements = _childElements.putIfAbsent(
        popUpList, () => SplayTreeMap<int, Element?>());
    final insertFirst = after == null;
    assert(insertFirst || childElements[index - 1] != null);
    _currentBeforeChild = insertFirst
        ? null
        : (childElements[index - 1]!.renderObject as RenderBox?);
    Element? newChild;
    try {
      _currentlyUpdatingPopUpList = popUpList;
      _currentlyUpdatingChildIndex = index;
      newChild = updateChild(childElements[index],
          build(index, popUpList: popUpList), _Slot(index, popUpList));
    } finally {
      _currentlyUpdatingChildIndex = null;
      _currentlyUpdatingPopUpList = null;
    }
    if (newChild != null) {
      childElements[index] = newChild;
    } else {
      childElements.remove(index);
    }
  });
}