calculateLeadingGarbage method
- required int firstIndex,
Returns the number of children preceding the firstIndex
that need to be
garbage collected.
See also:
- collectGarbage, which takes the leading and trailing number of children to be garbage collected.
- calculateTrailingGarbage, which similarly returns the number of trailing children to be garbage collected.
Implementation
@visibleForTesting
@protected
int calculateLeadingGarbage({required int firstIndex}) {
RenderBox? walker = firstChild;
int leadingGarbage = 0;
while (walker != null && indexOf(walker) < firstIndex) {
leadingGarbage += 1;
walker = childAfter(walker);
}
return leadingGarbage;
}