IndexedListView.separated constructor

IndexedListView.separated({
  1. Key? key,
  2. required IndexedScrollController controller,
  3. required IndexedWidgetBuilderOrNull itemBuilder,
  4. required IndexedWidgetBuilderOrNull separatorBuilder,
  5. IndexedWidgetBuilderOrNull emptyItemBuilder = defaultEmptyItemBuilder,
  6. Axis scrollDirection = Axis.vertical,
  7. bool reverse = false,
  8. ScrollPhysics? physics,
  9. EdgeInsets? padding,
  10. int? maxItemCount,
  11. int? minItemCount,
  12. bool addAutomaticKeepAlives = true,
  13. bool addRepaintBoundaries = true,
  14. double? cacheExtent,
})

Implementation

IndexedListView.separated({
  Key? key,
  required this.controller,
  required IndexedWidgetBuilderOrNull itemBuilder,
  required IndexedWidgetBuilderOrNull separatorBuilder,
  this.emptyItemBuilder = defaultEmptyItemBuilder,
  this.scrollDirection = Axis.vertical,
  this.reverse = false,
  this.physics,
  this.padding,
  int? maxItemCount,
  int? minItemCount,
  bool addAutomaticKeepAlives = true,
  bool addRepaintBoundaries = true,
  this.cacheExtent,
})  : separated = true,
      itemExtent = null,
      positiveChildrenDelegate = SliverChildBuilderDelegate(
        (BuildContext context, int index) {
          final _index = (index ~/ 2) + controller._originIndex;
          if ((minItemCount != null && _index < minItemCount) ||
              (maxItemCount != null && _index > maxItemCount))
            return emptyItemBuilder(context, _index);
          else
            return index.isEven
                ? (itemBuilder(context, _index) ?? emptyItemBuilder(context, _index))
                : separatorBuilder(context, _index);
        },
        addAutomaticKeepAlives: addAutomaticKeepAlives,
        addRepaintBoundaries: addRepaintBoundaries,
      ),
      negativeChildrenDelegate = SliverChildBuilderDelegate(
        (BuildContext context, int index) {
          final _index = ((-1 - index) ~/ 2) + controller._originIndex;
          if ((minItemCount != null && _index < minItemCount) ||
              (maxItemCount != null && _index > maxItemCount))
            return emptyItemBuilder(context, _index);
          else
            return index.isOdd
                ? (itemBuilder(context, _index) ?? emptyItemBuilder(context, _index))
                : separatorBuilder(context, _index);
        },
        addAutomaticKeepAlives: addAutomaticKeepAlives,
        addRepaintBoundaries: addRepaintBoundaries,
      ),
      super(key: key);