Skip to content

fix(listview): sync ListViewCore when ListView swaps scroll controller#2215

Merged
sharjeelyunus merged 1 commit into
mainfrom
cursor/critical-bug-identification-2378
May 19, 2026
Merged

fix(listview): sync ListViewCore when ListView swaps scroll controller#2215
sharjeelyunus merged 1 commit into
mainfrom
cursor/critical-bug-identification-2378

Conversation

@cursor
Copy link
Copy Markdown

@cursor cursor Bot commented May 16, 2026

Description

Fixes a correctness bug where ListViewCore bound CustomScrollView to a ScrollController only in initState. After ListViewState retargeted ListViewController.scrollController for draggable footer scope (see fix(layout): restore scroll controller when leaving footer scope), the inner scroll view kept using the previous controller while the public controller pointed at the sheet controller. That broke scrolling and any API that used scrollController (for example scrollToOffset) while the list was inside or after leaving the footer.

Related Issue

None filed; found during post-merge review of recent footer/ListView scroll work.

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update
  • Refactoring (no functional changes)

What Has Changed

  • ListViewCore now re-attaches scroll listeners when widget.scrollController changes, disposes the implicit controller when switching to an external controller, and keeps CustomScrollView aligned with the active controller.
  • Extended the existing footer regression test so Scrollable.controller must match ListViewController.scrollController both inside the footer scope and after restore.

How to Test

  1. From modules/ensemble, run flutter test test/widget/list_view_test.dart.
  2. Manually verify a ListView inside a draggable footer: scrolling should follow the sheet, and scroll APIs should target the same controller as the visible list.

Screenshots / Videos

N/A

Checklist

  • I have run flutter analyze and addressed any new warnings
  • I have run flutter test and all tests pass
  • I have tested my changes on the relevant platform(s)
  • I have updated documentation if needed
  • My changes do not introduce new warnings or errors

Note for reviewers: The automation environment did not have the Flutter SDK on PATH, so flutter test / flutter analyze were not executed here. Please run them locally before merge.

Open in Web View Automation 

ListViewCore captured ScrollController only in initState, so when
ListViewState retargeted the controller for FooterScope (owned vs sheet),
CustomScrollView kept using the stale controller while the public
ListViewController pointed at the footer controller.

Re-attach listeners when widget.scrollController changes and dispose the
implicit controller when switching to an external one.

Extend footer regression test to assert Scrollable.controller matches
ListViewController.scrollController in and out of footer scope.

Co-authored-by: Sharjeel Yunus <sharjeelyunus@users.noreply.github.com>
@sharjeelyunus sharjeelyunus marked this pull request as ready for review May 19, 2026 13:10
@sharjeelyunus sharjeelyunus merged commit c792a8a into main May 19, 2026
5 checks passed
@sharjeelyunus sharjeelyunus deleted the cursor/critical-bug-identification-2378 branch May 19, 2026 13:11
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.

2 participants