Repository navigation
v0.8.0-dev.1
Pre-release
Pre-release
Pre-release of the new masonry layout. Please try it and report any issue before the stable 0.8.0.
Highlights
MasonryGridViewandSliverMasonryGridkeep the placement of every child laid out once: no more jumps or children changing columns when scrolling back, and multiple masonry grids in aCustomScrollViewscroll correctly.- New optional
mainAxisExtentBuilder: when the extents of the children are known (for example the aspect ratio of images returned by an API), the children are placed without being built. Jumping far or changing the number of columns only builds the visible children, and the scroll extent is exact from the start.
MasonryGridView.count(
crossAxisCount: 3,
itemCount: photos.length,
mainAxisExtentBuilder: (index, crossAxisExtent) =>
crossAxisExtent / photos[index].aspectRatio,
itemBuilder: (context, index) => Image.network(photos[index].url),
);Behaviour changes
- Reaching a child far in a masonry grid lays out all the children before it once (like
ListView), unlessmainAxisExtentBuilderis provided. - Changing the
crossAxisCountkeeps the first visible child in place. - Changing the width without changing the
crossAxisCountkeeps the state of the visible children; the previous children are placed again when scrolling back. SliverMasonryGridreplaces the children moved with keys, likeSliverList.
Breaking changes
- Minimal versions: Dart 3.2, Flutter 3.16.
SliverMasonryGridParentData.lastMainAxisExtenthas been removed.
Fixed issues
#338, #335, #299, #286, #265, #244, #330, #356, #313, #105.
See the CHANGELOG for the details.