getIntrinsicDimension method Null safety

double getIntrinsicDimension(
  1. RenderBox? firstChild,
  2. double mainChildSizeGetter(
    1. RenderBox child
    )
)

Helper function for calculating the intrinsics metrics of a Stack.

Implementation

static double getIntrinsicDimension(RenderBox? firstChild, double Function(RenderBox child) mainChildSizeGetter) {
  double extent = 0.0;
  RenderBox? child = firstChild;
  while (child != null) {
    final StackParentData childParentData = child.parentData! as StackParentData;
    if (!childParentData.isPositioned) {
      extent = math.max(extent, mainChildSizeGetter(child));
    }
    assert(child.parentData == childParentData);
    child = childParentData.nextSibling;
  }
  return extent;
}