insertAndLayoutChild method

  1. @protected
RenderBox? insertAndLayoutChild(
  1. _PopUpList? popUpList,
  2. BoxConstraints childConstraints, {
  3. required RenderBox? after,
  4. bool parentUsesSize = false,
})

Called during layout to create, add, and layout the child after the given child.

Calls RenderSliverBoxChildManager.createChild to actually create and add the child if necessary. The child may instead be obtained from a cache; see MultiSliverMultiBoxAdaptorParentData.keepAlive.

Returns the new child. It is the responsibility of the caller to configure the child's scroll offset.

Children after the after child may be removed in the process. Only the new child may be added.

Implementation

@protected
RenderBox? insertAndLayoutChild(
  _PopUpList? popUpList,
  BoxConstraints childConstraints, {
  required RenderBox? after,
  bool parentUsesSize = false,
}) {
  assert(_debugAssertChildListLocked());
  assert(after != null);
  final index = indexOf(after!) + 1;
  _createOrObtainChild(popUpList, index, after: after);
  final child = childAfter(after);
  if (child != null && indexOf(child) == index) {
    child.layout(childConstraints, parentUsesSize: parentUsesSize);
    return child;
  }
  if (popUpList == null) childManager.setDidUnderflow(true);
  return null;
}