indexOfFirstChild property Null safety

  1. @override
int indexOfFirstChild
override

The index of the first child of the viewport relative to the center child.

For example, the center child has index zero and the first child in the reverse growth direction has index -1.

Implementation

@override
int get indexOfFirstChild {
  assert(center != null);
  assert(center!.parent == this);
  assert(firstChild != null);
  int count = 0;
  RenderSliver? child = center;
  while (child != firstChild) {
    count -= 1;
    child = childBefore(child!);
  }
  return count;
}