SliverGrid.list constructor
Creates a sliver that places multiple box children in a two dimensional arrangement.
To learn more about slivers, see CustomScrollView.slivers.
Uses a SliverChildListDelegate as the delegate.
The addAutomaticKeepAlives argument corresponds to the
SliverChildListDelegate.addAutomaticKeepAlives property. The
addRepaintBoundaries argument corresponds to the
SliverChildListDelegate.addRepaintBoundaries property. The
addSemanticIndexes argument corresponds to the
SliverChildListDelegate.addSemanticIndexes property. The
semanticIndexOffset argument corresponds to the
SliverChildListDelegate.semanticIndexOffset property.
This example, which would be inserted into a CustomScrollView.slivers
list, shows a grid of Container widgets.
link
SliverGrid.list(
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 3,
),
children: <Widget>[
Container(color: Colors.red),
Container(color: Colors.green),
Container(color: Colors.blue),
Container(color: Colors.yellow),
Container(color: Colors.orange),
Container(color: Colors.purple),
],
);
Implementation
SliverGrid.list({
super.key,
required this.gridDelegate,
required List<Widget> children,
bool addAutomaticKeepAlives = true,
bool addRepaintBoundaries = true,
bool addSemanticIndexes = true,
int semanticIndexOffset = 0,
}) : super(
delegate: SliverChildListDelegate(
children,
addAutomaticKeepAlives: addAutomaticKeepAlives,
addRepaintBoundaries: addRepaintBoundaries,
addSemanticIndexes: addSemanticIndexes,
semanticIndexOffset: semanticIndexOffset,
),
);