Skip to main content

MasonryGrid

The MasonryGrid widget is a staggered grid that packs tiles of varying heights together with no gaps.
Use it to arrange content whose items differ in height — like a gallery of cards — across multiple columns.

info

This widget is locked on the Free plan. It's available on the Pro and Enterprise plans.

Definition and role

The MasonryGrid widget splits its child items across the number of columns you set in crossAxisCount, then stacks them tightly from the top to match each tile's height. Unlike a regular grid, tiles fill the space without gaps even when their heights vary. Items repeat as many times as the data count (itemCount), using one repeated child as the template.

  • Category: Layouts
  • Size when dropped: inside a parent layout (Row, Column, Stack, and so on) it starts at 200 x 150. Placed at the top level with no parent, it appears larger to fill the canvas.

Features

FeatureDescription
Staggered layoutPacks tiles tightly from the top with no gaps, even when their heights differ.
Column countSet how many columns sit in one row (the cross axis) with crossAxisCount.
Item repetitionRenders the child item itemCount times.
Spacing controlAdjust the vertical and horizontal gaps between tiles with mainAxisSpacing and crossAxisSpacing.
Scroll settingsSet the scroll direction (scrollDirection), reverse order (reverse), physics (physics), and more.

How to use

  1. Open the Layouts category in the left widget palette.
  2. Drag and drop the MasonryGrid item onto the canvas.
  3. In the Properties panel on the right, set the column count with crossAxisCount.
  4. Set how many items to repeat with itemCount, then build the child widget that repeats.
  5. If needed, adjust the tile gaps with mainAxisSpacing and crossAxisSpacing.

Properties

PropertyDescriptionDefaultValue / Type
scrollDirectionScroll (layout) directionverticalhorizontal, vertical
reverseReverse the order items are laid out inOff (false)true / false
controllerScroll controller to attachNot setScroll controller
primaryWhether to use this as the primary scroll viewNot settrue / false
physicsScroll physicsNot setScroll physics value
shrinkWrapShrink the layout to fit its contentOn (true)true / false
paddingPadding inside the gridNot setInset value
crossAxisCountNumber of columns in one row (the cross axis)1Number (1 or higher)
mainAxisSpacingTile gap along the main axis (vertical)0Number (0 or higher)
crossAxisSpacingTile gap along the cross axis (horizontal)0Number (0 or higher)
itemCountNumber of items to generate0Number
addAutomaticKeepAlivesKeep the state of off-screen itemsOn (true)true / false
addRepaintBoundariesAdd a repaint boundary to each itemOn (true)true / false
addSemanticIndexesGive each item a semantic indexOn (true)true / false
cacheExtentSize of the cache area rendered aheadNot setNumber
semanticChildCountNumber of semantic childrenNot setNumber
dragStartBehaviorWhat counts as the start of a dragstartdown, start
keyboardDismissBehaviorHow the keyboard closes while scrollingmanualmanual, onDrag
restorationIdID for restoring the scroll positionNot setString
clipBehaviorHow children are clippedhardEdgenone, hardEdge, antiAlias, antiAliasWithSaveLayer

Notes and tips

warning

Set crossAxisCount to 1 or higher. The larger the value, the more columns fit in a single row.

tip

shrinkWrap defaults to true, so the grid takes up only as much height as its content. That's useful when you place it inside another scrolling area.

Learn more

tip

For the full Widget Control (Property, Method, Event) you can use to drive this widget from a script, visit MasonryGrid Widget Control.