build method
- BuildContext context,
- int index
override
Copied from SliverChildBuilderDelegate.build. This method has been modified in order to handle the new animating attribute that indicates when an item should be build in an animating way or not. In addition, the new callback AnimatedSliverChildBuilderDelegate.childCount will be called instead of just an attribute.
Implementation
@override
Widget build(BuildContext context, int index) {
assert(builder != null);
var animating =
(context as AnimatedSliverMultiBoxAdaptorElement)?._animating ?? true;
var count = childCount?.call();
if (index < 0 || (count != null && index >= count)) return null;
Widget child;
try {
child = builder(context, index, animating);
} catch (exception, stackTrace) {
child = _createErrorWidget(exception, stackTrace);
}
if (child == null) {
return null;
}
final Key key = child.key != null ? _SaltedValueKey(child.key) : null;
if (addRepaintBoundaries) child = RepaintBoundary(child: child);
if (addSemanticIndexes && !animating) {
final semanticIndex = semanticIndexCallback(child, index);
if (semanticIndex != null) {
child = IndexedSemantics(
index: semanticIndex + semanticIndexOffset, child: child);
}
}
if (addAutomaticKeepAlives && !animating) {
child = AutomaticKeepAlive(child: child);
}
return KeyedSubtree(child: child, key: key);
}