createChild method

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

Creates a new child at the given index and updates it to the child list of RenderListWheelViewport. If no child corresponds to index, then do nothing.

It is possible to create children with negative indices.

Implementation

@override
void createChild(int index, { required RenderBox? after }) {
  owner!.buildScope(this, () {
    final bool insertFirst = after == null;
    assert(insertFirst || _childElements[index - 1] != null);
    final Element? newChild =
      updateChild(_childElements[index], retrieveWidget(index), index);
    if (newChild != null) {
      _childElements[index] = newChild;
    } else {
      _childElements.remove(index);
    }
  });
}