createChild method

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

Copied from SliverMultiBoxAdaptorElement.createChild.

Implementation

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