Home

GridViewbuildergridDelegate

GridView.builder is a constructor that creates a scrollable, lazily built grid. The gridDelegate parameter specifies how the grid should arrange its tiles. It takes a SliverGridDelegate, an abstract class that describes the layout geometry used during the grid’s layout phase. Concrete implementations determine how many tiles fit in the cross axis and how much space each tile receives.

The two most commonly used delegates are SliverGridDelegateWithFixedCrossAxisCount and SliverGridDelegateWithMaxCrossAxisExtent. The first fixes the number of

GridDelegate is consulted during layout and does not itself create widgets; GridView.builder provides itemBuilder to lazily

Ensure the gridDelegate is supplied to GridView.builder; omitting it leaves the grid without a layout policy.

columns
(crossAxisCount)
and
allows
configuring
spacing
(mainAxisSpacing,
crossAxisSpacing)
and
tile
aspect
ratio
(childAspectRatio).
The
second
fixes
the
maximum
extent
of
a
tile
along
the
cross
axis
(maxCrossAxisExtent),
and
similarly
supports
spacing
and
aspect
ratio.
The
result
is
a
grid
that
adapts
to
screen
size
while
obeying
the
specified
constraints.
instantiate
tiles
as
they
scroll
into
view.
The
grid
delegate
thus
enables
responsive,
dynamic
grids
suitable
for
image
galleries,
product
listings,
and
other
grid-based
UI.
Related
concepts
include
GridView,
SliverGridDelegate,
and
the
concrete
delegates
mentioned
above.