What’s SliverGrid?

A sliver that places multiple box children in a two dimensional arrangement.

Check the official documentation for more.

SliverGrid explained for Web Developers

SliverGrid places its children in arbitrary positions determined by gridDelegate. Each child is forced to have the size specified by the gridDelegate. The main axis direction of a grid is the direction in which it scrolls; the cross axis direction is the orthogonal direction.

Example Code

Here is an example of how to use SliverGrid:

SliverGrid(
gridDelegate: const SliverGridDelegateWithMaxCrossAxisExtent(
maxCrossAxisExtent: 200.0,
mainAxisSpacing: 10.0,
crossAxisSpacing: 10.0,
childAspectRatio: 4.0,
),
delegate: SliverChildBuilderDelegate(
(BuildContext context, int index) {
return Container(
alignment: Alignment.center,
color: Colors.teal[100 * (index % 9)],
child: Text('grid item $index'),
);
},
childCount: 20,
),
)

SliverGrid Remarks

Using SliverGrid allows for efficient and flexible layouts in Flutter applications, especially when dealing with large datasets.

Bootstrap Your app with ShipFlutter

A fully customizable starter kit to seamlessly launch responsive Android, iOS, and Web apps with Flutter powered by Firebase and Vertex AI.