Make auto_scroll follow in-place content growth#6637
Open
FeodorFitsner wants to merge 1 commit into
Open
Conversation
auto_scroll only scrolled to the end from ScrollableControl.build(), so it followed added children but not content that grows *in place* (e.g. text streamed into an existing child) — that never rebuilds the scrollable. - Add a ScrollMetricsNotification listener that re-pins to the end whenever the scroll extent grows, even without a rebuild. - Track the user's position; suspend pinning while they've scrolled away from the end and resume when they return. - Add an auto_scroll_animation property (duration + curve) to control the scroll; defaults to the historical 1s ease, set duration 0 for an instant jump.
Deploying flet-website-v2 with
|
| Latest commit: |
a86251e
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://176d86a3.flet-website-v2.pages.dev |
| Branch Preview URL: | https://auto-scroll-follow-content-g.flet-website-v2.pages.dev |
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.
Problem
auto_scrollonly scrolls to the end from insideScrollableControl.build(). That fires when the scrollable rebuilds — e.g. a child is added — but not when existing content grows in place, such as text streamed into an existing child. So an auto-scrolling chat/log follows new messages but falls behind while a single message grows.Changes
packages/flet/lib/src/controls/scrollable_control.dart:NotificationListener<ScrollMetricsNotification>that re-pins to the end whenever the scroll extent grows, even when this widget doesn't rebuild.ScrollControllerlistener, 40px threshold): pinning pauses while the user has scrolled away from the end and resumes when they scroll back — so it never yanks a user who scrolled up to read history.auto_scroll_animationproperty (duration + curve). Defaults to the historical 1sease; set a duration of0for an instant jump (nice for fast, token-by-token streaming).sdk/python/packages/flet/src/flet/controls/scrollable_control.py:auto_scroll_animation: Optional[AnimationValue]property and update theauto_scrolldocs.Notes
auto_scroll=Trueusers keep the 1s ease behavior and additionally gain in-place-growth following.flutter analyzeon the changed control: no issues.Summary by Sourcery
Enhance scrollable controls so auto-scroll stays pinned to the end while content grows in place and remains user-friendly when the user scrolls away.
New Features:
Documentation: