IndexedListView.builder constructor

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

Implementation

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