perf(grids): rebuild media grids on width change, not every scroll tick

This commit is contained in:
edde746
2026-06-12 07:18:34 +02:00
parent 2b34f4a9d7
commit 03c623e8c7
9 changed files with 359 additions and 149 deletions
+5 -3
View File
@@ -54,9 +54,11 @@ class GridSizeCalculator {
/// is added to the denominator only, not the numerator:
/// `(crossAxisExtent / (maxCrossAxisExtent + crossAxisSpacing)).ceil()`
///
/// [crossAxisExtent] should come from layout constraints (e.g. `SliverLayoutBuilder`
/// or `LayoutBuilder`), not from `MediaQuery`, to account for sidebars or other
/// elements that reduce the grid's actual width.
/// [crossAxisExtent] should come from layout constraints (e.g.
/// `SliverCrossAxisLayoutBuilder` or `LayoutBuilder`), not from `MediaQuery`,
/// to account for sidebars or other elements that reduce the grid's actual
/// width. Never use a plain `SliverLayoutBuilder` for this: its constraints
/// include the scroll offset, so it rebuilds the whole grid every scroll tick.
static int getColumnCount(
double crossAxisExtent,
double maxCrossAxisExtent, {