{{ message }}
Repository navigation
Fix double detach of kept-alive children in RenderTwoDimensionalViewport - #194917
Open
JayeshJain25 wants to merge 1 commit into
Open
JayeshJain25 wants to merge 1 commit into
JayeshJain25 wants to merge 1 commit into
Conversation
A kept-alive child lives in both `_children` and `_keepAliveBucket`, so `attach` and `detach` visited it twice and tripped the `_owner != null` assertion (e.g. a TableView inside a ListView with a selected cell scrolled away). Fixes flutter#194718
JayeshJain25
marked this pull request as ready for review
October 21, 2026 04:18
Contributor
There was a problem hiding this comment.
Code Review
This pull request modifies RenderTwoDimensionalViewport to de-duplicate children present in both _children and _keepAliveBucket maps before calling attach or detach on them. Additionally, a regression test has been added to verify that kept-alive children are not detached twice when the viewport is removed. I have no further feedback to provide.
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.

A kept-alive child of
RenderTwoDimensionalViewportis present in both_childrenand_keepAliveBucket(_cacheKeepAlivesadds it to the bucket without removing it from_children).attachanddetachlooped over both maps, so such a child was attached/detached twice, tripping the_owner != nullassertion inRenderObject.detach(e.g. aTableViewinside aListViewwith a selected cell scrolled away, or any cell usingAutomaticKeepAliveClientMixin).This de-duplicates the children in
attachanddetach. Removing the child from_childrenin_cacheKeepAliveswas tried first but breaks existing keep-alive tests, since other code relies on it staying there.Fixes #194718
Pre-launch Checklist
///).Review-Before-PR