measureItems method
Future<_Measure>
measureItems(
- _Cancelled? cancelled,
- int count,
- IndexedWidgetBuilder builder,
- double startingSize,
- int startingCount,
override
Returns the sum of the sizes of a bunch of items, built using the specified builder.
Implementation
@override
Future<_Measure> measureItems(
_Cancelled? cancelled,
int count,
IndexedWidgetBuilder builder,
double startingSize,
int startingCount) async {
assert(count > 0);
final maxSize = constraints.remainingCacheExtent;
assert(maxSize >= 0.0);
var size = startingSize;
int i;
for (i = startingCount; i < count; i++) {
if (size >= maxSize) break;
await Future.delayed(Duration(milliseconds: 0), () {
if (cancelled?.value ?? false) return _Measure.zero;
size += measureItem(
builder.call(childManager, i - startingCount), childConstraints);
});
if (cancelled?.value ?? false) return _Measure.zero;
}
if (i < count) size *= (count / i);
return _Measure(size, i < count);
}