fix: ScrollableControl.auto_scroll not working when scroll property is not explicitly set#6404
Open
ndonkoHenri wants to merge 1 commit intomainfrom
Open
fix: ScrollableControl.auto_scroll not working when scroll property is not explicitly set#6404ndonkoHenri wants to merge 1 commit intomainfrom
ScrollableControl.auto_scroll not working when scroll property is not explicitly set#6404ndonkoHenri wants to merge 1 commit intomainfrom
Conversation
Deploying flet-examples with
|
| Latest commit: |
409ebd8
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://4f9cc673.flet-examples.pages.dev |
| Branch Preview URL: | https://fix-autoscroll.flet-examples.pages.dev |
Deploying flet-website-v2 with
|
| Latest commit: |
409ebd8
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://4248c764.flet-website-v2.pages.dev |
| Branch Preview URL: | https://fix-autoscroll.flet-website-v2.pages.dev |
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes ScrollableControl.auto_scroll so it works even when the scroll property isn’t explicitly set (i.e., when no scrollbar configuration is provided).
Changes:
- Removes the dependency on
scrollConfiguration != nullfor triggeringauto_scroll. - Always schedules a post-frame scroll-to-end animation when
auto_scrollis enabled.
Comments suppressed due to low confidence (1)
packages/flet/lib/src/controls/scrollable_control.dart:107
auto_scrollnow schedules ananimateTo()even whenscrollConfigurationis null. In cases where this widget created its own_controllerand the child is not wrapped into aScrollable(e.g.,wrapIntoScrollableViewis true butscrollConfiguration == nullreturnswidget.child),_controllermay have no clients and_controller.position/animateTo()will throw at runtime. Consider guarding inside the post-frame callback withif (!mounted || !_controller.hasClients) return;before reading_controller.position, and optionally avoid animating when already at the target offset.
if (widget.control.getBool("auto_scroll", false)!) {
WidgetsBinding.instance.addPostFrameCallback((_) {
_controller.animateTo(
_controller.position.maxScrollExtent,
duration: const Duration(seconds: 1),
curve: Curves.ease,
);
});
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Contributor
|
Change the base of this PR to |
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.
Fix #6397
The
auto_scrollfeature on scrollable controls (ListView, GridView, Column, Row, etc.) silently did nothing unless thescrollproperty was also explicitly set. This was because the auto-scroll logic inscrollable_control.dartwas nested inside ascrollConfiguration != nullcheck. Moved it outside so auto-scroll works independently.Test Code
https://flet.dev/docs/controls/listview/#examples
Summary by Sourcery
Bug Fixes: