Use SliverList and cache content height#1802
Merged
QuncCccccc merged 4 commits intomainfrom May 12, 2023
Merged
Conversation
Contributor
|
You'll need to pull from |
6f2530f to
e27caad
Compare
domesticmouse
approved these changes
May 11, 2023
HansMuller
approved these changes
May 11, 2023
Comment on lines
+118
to
+121
| // Based on the fact that the list content is fixed, we cache | ||
| // the height of the content during the first-time scrolling. | ||
| // The cached height can be used to override | ||
| // `SliverChildDelegate.estimateMaxScrollOffset`, to avoid a shaking scrollbar. |
There was a problem hiding this comment.
Suggested change
| // Based on the fact that the list content is fixed, we cache | |
| // the height of the content during the first-time scrolling. | |
| // The cached height can be used to override | |
| // `SliverChildDelegate.estimateMaxScrollOffset`, to avoid a shaking scrollbar. | |
| // If the content of a CustomScrollView does not change, then it's | |
| // safe to cache the heights of each item as they are laid out. The | |
| // sum of the cached heights are returned by an override of | |
| // `SliverChildDelegate.estimateMaxScrollOffset`. The default version | |
| // of this method bases its estimate on the average height of the | |
| // visible items. The override ensures that the scrollbar thumb's | |
| // size, which depends on the max scroll offset, will shrink smoothly | |
| // as the contents of the list are exposed for the first time, and | |
| // then remain fixed. |
| } | ||
| } | ||
|
|
||
| // Based on the fact that the list content is fixed, we cache |
There was a problem hiding this comment.
See suggested rewrite for the experimental version of this comment
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.
Fixes #1694
This PR is to fix the shaking scrollbar problem. We replace the
ListViews withCustomScrollViewand cache the content height to provide a better estimation for the max scroll offset.Same changes are applied to both Material 3 demo in the root directory and the M3 demo in the
/experimental/Screen.Recording.2023-05-10.at.4.05.27.PM.mov
two_cols.mov
Pre-launch Checklist
///).