Skip to content

fix: ScrollableControl.auto_scroll not working when scroll property is not explicitly set#6404

Open
ndonkoHenri wants to merge 1 commit intomainfrom
fix-autoscroll
Open

fix: ScrollableControl.auto_scroll not working when scroll property is not explicitly set#6404
ndonkoHenri wants to merge 1 commit intomainfrom
fix-autoscroll

Conversation

@ndonkoHenri
Copy link
Copy Markdown
Contributor

@ndonkoHenri ndonkoHenri commented Apr 10, 2026

Fix #6397

The auto_scroll feature on scrollable controls (ListView, GridView, Column, Row, etc.) silently did nothing unless the scroll property was also explicitly set. This was because the auto-scroll logic in scrollable_control.dart was nested inside a scrollConfiguration != null check. Moved it outside so auto-scroll works independently.

Test Code

https://flet.dev/docs/controls/listview/#examples

Summary by Sourcery

Bug Fixes:

  • Fix auto_scroll on scrollable controls so it works even when the scroll property is not explicitly set.

@ndonkoHenri ndonkoHenri requested a review from Copilot April 10, 2026 13:50
Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We've reviewed this pull request using the Sourcery rules engine

@cloudflare-workers-and-pages
Copy link
Copy Markdown

Deploying flet-examples with  Cloudflare Pages  Cloudflare Pages

Latest commit: 409ebd8
Status: ✅  Deploy successful!
Preview URL: https://4f9cc673.flet-examples.pages.dev
Branch Preview URL: https://fix-autoscroll.flet-examples.pages.dev

View logs

@cloudflare-workers-and-pages
Copy link
Copy Markdown

Deploying flet-website-v2 with  Cloudflare Pages  Cloudflare Pages

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

View logs

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 != null for triggering auto_scroll.
  • Always schedules a post-frame scroll-to-end animation when auto_scroll is enabled.
Comments suppressed due to low confidence (1)

packages/flet/lib/src/controls/scrollable_control.dart:107

  • auto_scroll now schedules an animateTo() even when scrollConfiguration is null. In cases where this widget created its own _controller and the child is not wrapped into a Scrollable (e.g., wrapIntoScrollableView is true but scrollConfiguration == null returns widget.child), _controller may have no clients and _controller.position / animateTo() will throw at runtime. Consider guarding inside the post-frame callback with if (!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.

@FeodorFitsner
Copy link
Copy Markdown
Contributor

Change the base of this PR to release/v0.85.0 and add changelog record.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: The "auto scroll" property of the "Listview" is not working

3 participants