AppendedSliverChildBuilderDelegate.separated constructor
AppendedSliverChildBuilderDelegate.separated({
- required IndexedWidgetBuilder builder,
- required int childCount,
- required IndexedWidgetBuilder separatorBuilder,
- WidgetBuilder? appendixBuilder,
- bool addAutomaticKeepAlives = true,
- bool addRepaintBoundaries = true,
- bool addSemanticIndexes = true,
Implementation
AppendedSliverChildBuilderDelegate.separated({
required IndexedWidgetBuilder builder,
required int childCount,
required IndexedWidgetBuilder separatorBuilder,
WidgetBuilder? appendixBuilder,
bool addAutomaticKeepAlives = true,
bool addRepaintBoundaries = true,
bool addSemanticIndexes = true,
}) : this(
builder: (context, index) {
final itemIndex = index ~/ 2;
if (index.isEven) {
return builder(context, itemIndex);
}
return separatorBuilder(context, itemIndex);
},
childCount: math.max(
0,
childCount * 2 - (appendixBuilder != null ? 0 : 1),
),
appendixBuilder: appendixBuilder,
addAutomaticKeepAlives: addAutomaticKeepAlives,
addRepaintBoundaries: addRepaintBoundaries,
addSemanticIndexes: addSemanticIndexes,
semanticIndexCallback: (_, index) => index.isEven ? index ~/ 2 : null,
);