Skip to content

v0.8.0-dev.1

Pre-release
Pre-release

Choose a tag to compare

@letsar letsar released this 03 Nov 20:32
· 18 commits to master since this release

Pre-release of the new masonry layout. Please try it and report any issue before the stable 0.8.0.

Highlights

  • MasonryGridView and SliverMasonryGrid keep the placement of every child laid out once: no more jumps or children changing columns when scrolling back, and multiple masonry grids in a CustomScrollView scroll 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), unless mainAxisExtentBuilder is provided.
  • Changing the crossAxisCount keeps the first visible child in place.
  • Changing the width without changing the crossAxisCount keeps the state of the visible children; the previous children are placed again when scrolling back.
  • SliverMasonryGrid replaces the children moved with keys, like SliverList.

Breaking changes

  • Minimal versions: Dart 3.2, Flutter 3.16.
  • SliverMasonryGridParentData.lastMainAxisExtent has been removed.

Fixed issues

#338, #335, #299, #286, #265, #244, #330, #356, #313, #105.

See the CHANGELOG for the details.