SliverFixedExtentList.list constructor

SliverFixedExtentList.list({
  1. Key? key,
  2. required List<Widget> children,
  3. required double itemExtent,
  4. bool addAutomaticKeepAlives = true,
  5. bool addRepaintBoundaries = true,
  6. bool addSemanticIndexes = true,
})

A sliver that places multiple box children in a linear array along the main axis.

SliverFixedExtentList places its children in a linear array along the main axis starting at offset zero and without gaps. Each child is forced to have the itemExtent in the main axis and the SliverConstraints.crossAxisExtent in the cross axis.

This constructor uses a list of Widgets to build the sliver.

The addAutomaticKeepAlives argument corresponds to the SliverChildBuilderDelegate.addAutomaticKeepAlives property. The addRepaintBoundaries argument corresponds to the SliverChildBuilderDelegate.addRepaintBoundaries property. The addSemanticIndexes argument corresponds to the SliverChildBuilderDelegate.addSemanticIndexes property.

This example, which would be inserted into a CustomScrollView.slivers list, shows an infinite number of items in varying shades of blue:
link
SliverFixedExtentList.list(
  itemExtent: 50.0,
  children: const <Widget>[
    Text('Hello'),
    Text('World!'),
  ],
);

Implementation

SliverFixedExtentList.list({
  super.key,
  required List<Widget> children,
  required this.itemExtent,
  bool addAutomaticKeepAlives = true,
  bool addRepaintBoundaries = true,
  bool addSemanticIndexes = true,
}) : super(delegate: SliverChildListDelegate(
       children,
       addAutomaticKeepAlives: addAutomaticKeepAlives,
       addRepaintBoundaries: addRepaintBoundaries,
       addSemanticIndexes: addSemanticIndexes,
     ));