mosaic_grid 0.1.1
mosaic_grid: ^0.1.1 copied to clipboard
Lazy grids whose tiles size themselves: aligned rows that grow to their tallest card, masonry columns, multi-column tiles, paging and jump-to-item.
Changelog #
0.1.1 #
Fixes #
onEndReachedfires again when a new page arrives and still does not fill the viewport. Only the first page was checked: with nothing to scroll, no scroll metric changed, no notification came, and the page after it was never asked for.onEndReachedno longer stays silent after the list is replaced by another one of the same length, such as the first page of a new search. It fired at most once peritemCountand never re-armed; now scrolling away from the end and back re-arms it.
Added #
MosaicGrid.endReachedKey— what the items were loaded for (a search term, a filter). When it changes, the grid forgets thatonEndReachedalready fired and checks the end again: the fix for a list replaced in place while the view stays at the end, which no scroll or change ofitemCountreveals.
0.1.0 #
First release.
Layouts #
MosaicLayout.rows— tiles fill rows from the start edge, and every row is as tall as its tallest tile.MosaicRowFitdecides what shorter tiles do:stretch(the default),start,centerorend.MosaicLayout.masonry— every tile keeps its height and drops into the column that ends first.columnSpan— tiles spanning several columns, in both layouts, built lazily.
Columns #
MosaicColumns.count,MosaicColumns.minExtent(with an optionalmaxCount) andMosaicColumns.maxExtent, resolved from the grid's own cross-axis extent on every layout.
Widgets #
MosaicGrid— a scroll view withheader,footer,onEndReached(at most once peritemCount) and every usual scroll view option.SliverMosaicGrid— the same grid as a sliver, forCustomScrollView.MosaicController—jumpToIndexandanimateToIndex, withalignment, exact even for items never built.
Behaviour #
- Positions come from a ledger recorded in index order from the first item, so scrolling back up never drifts.
- Tiles already laid out are not laid out again while scrolling; stretched rows
need no
IntrinsicHeight. - A tile above the viewport that changes size does not move the visible content, and neither does a change of column count.
- Measuring is time-sliced: a long jump (a scrollbar drag, a far
jumpTo) fills in over a few frames instead of blocking one. - Masonry lookups and re-flows stay logarithmic in the number of items, even when one column runs far longer than the others.
- Vertical and horizontal scrolling, right-to-left, keep-alives, semantics indexes and keyed reordering.
