IndexedListView.separated constructor
IndexedListView.separated({
- Key? key,
- required IndexedScrollController controller,
- required IndexedWidgetBuilderOrNull itemBuilder,
- required IndexedWidgetBuilderOrNull separatorBuilder,
- IndexedWidgetBuilderOrNull emptyItemBuilder = defaultEmptyItemBuilder,
- Axis scrollDirection = Axis.vertical,
- bool reverse = false,
- ScrollPhysics? physics,
- EdgeInsets? padding,
- int? maxItemCount,
- int? minItemCount,
- bool addAutomaticKeepAlives = true,
- bool addRepaintBoundaries = true,
- 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);