AppendedSliverChildBuilderDelegate.separated constructor

AppendedSliverChildBuilderDelegate.separated({
  1. required IndexedWidgetBuilder builder,
  2. required int childCount,
  3. required IndexedWidgetBuilder separatorBuilder,
  4. WidgetBuilder? appendixBuilder,
  5. bool addAutomaticKeepAlives = true,
  6. bool addRepaintBoundaries = true,
  7. 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,
      );