-
Notifications
You must be signed in to change notification settings - Fork 7.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use SliverList and cache content height #1802
Conversation
You'll need to pull from |
6f2530f
to
e27caad
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
// 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See suggested rewrite for the experimental version of this comment
This reverts commit 1d6e5a0.
Fixes #1694
This PR is to fix the shaking scrollbar problem. We replace the
ListView
s withCustomScrollView
and 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
///
).