perf(grid): rebuild on horizontal scroll only when the visible column window changes (#879) - #971
Merged
ZhuchkaTriplesix merged 1 commit intoSep 25, 2026
Conversation
… window changes (Closes #879) _onHorizontalScroll called setState for every 0.5px of movement, rebuilding the whole virtualized body on each pan frame of a wide grid. The horizontal scroll view already translates header and body together; the offset only decides which columns are built. Recompute the visible column window from the last build's widths and rebuild only when it differs, otherwise just remember the offset.
ZhuchkaTriplesix
deleted the
issue/879-grid-horizontal-scroll-no-setstate
branch
September 28, 2026 08:13
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Описание изменений
_onHorizontalScrollделалsetStateна каждые 0.5 px сдвига, из-за чего на широкой таблице перестраивалось всё виртуализированное тело на каждом кадре панорамирования.SingleChildScrollViewуже сам сдвигает шапку и тело вместе, а_scrollOffsetнужен только для выбора построенных колонок (виртуализация по колонкам). Поэтому теперь по смещению пересчитывается окно колонок (computeVisibleColumnWindow) по данным последнего build (_currentDisplayWidths,_currentWindow), иsetStateвызывается только если окно изменилось. Иначе смещение просто запоминается.result_grid_sorting_model_test.dart(3 новых): небольшой сдвиг внутри окна не пересоздаёт строки (проверяется идентичность виджета строки, тест падает на старом коде), сдвиг до конца строит новые колонки, возврат назад восстанавливает первые. Весь файл прогнал локально, 13 проходят.Не входит
Автоподбор ширины колонок в
LayoutBuilder(как в issue). Замер FPS при 120 Hz не делал.Связанные Issue
Closes #879