fix(listview): sync ListViewCore when ListView swaps scroll controller#2215
Merged
Merged
Conversation
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>
This was referenced May 17, 2026
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.
Description
Fixes a correctness bug where
ListViewCoreboundCustomScrollViewto aScrollControlleronly ininitState. AfterListViewStateretargetedListViewController.scrollControllerfor draggable footer scope (seefix(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 usedscrollController(for examplescrollToOffset) 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
What Has Changed
ListViewCorenow re-attaches scroll listeners whenwidget.scrollControllerchanges, disposes the implicit controller when switching to an external controller, and keepsCustomScrollViewaligned with the active controller.Scrollable.controllermust matchListViewController.scrollControllerboth inside the footer scope and after restore.How to Test
modules/ensemble, runflutter test test/widget/list_view_test.dart.ListViewinside 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
flutter analyzeand addressed any new warningsflutter testand all tests passNote for reviewers: The automation environment did not have the Flutter SDK on
PATH, soflutter test/flutter analyzewere not executed here. Please run them locally before merge.