New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix ReorderableListView's use of child keys (#41334) #41338
Conversation
ReorderableListView was constructing a GlobalObjectKey using the child key as the value. This only had the intended behavior if the child key was identical across build method invocations. The new strategy is to scope the child key's value to the State object's identity, allowing child keys to have value compare semantics while disambiguating among different list view instances.
It looks like this pull request may not have tests. Please make sure to add tests before merging. While there are exceptions to this rule, if this patch modifies code it is probably not an exception. Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
@Hixie ready for review, I think. |
This is great. |
Some analyzer warnings but otherwise LGTM. |
…41338) ReorderableListView was constructing a GlobalObjectKey using the child key as the value. This only had the intended behavior if the child key was identical across build method invocations. The new strategy is to scope the child key's value to the State object's identity, allowing child keys to have value compare semantics while disambiguating among different list view instances.
@Hixie Looks like this change has broken something. This is gallery ReorderableList demo: https://github.com/flutter/flutter/blob/master/examples/flutter_gallery/lib/demo/material/reorderable_list_demo.dart
I am experiencing the same issue in my current app I am building. |
cc @krisgiesing can you revert while the issue is being investigated? I wonder what's going on... |
The issue preventing this from landing has been narrowed down to a test that doesn't use ReorderableListView, captured in #43780. |
…lutter#41338)" (flutter#41931) This reverts commit 2b138fd.
Description
ReorderableListView was constructing a GlobalObjectKey using the child key as the value. This only had the intended behavior if the child key was identical across build method invocations.
The new strategy is to scope the child key's value to the State object's identity, allowing child keys to have value compare semantics while disambiguating among different list view instances.
Related Issues
#41334 - fixed
Tests
Updated test/material/reorderable_list_test.dart to add 'Preserves children states across reorder when keys are not identical'.
Checklist
Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes (
[x]
). This will ensure a smooth and quick review process.///
).flutter analyze --flutter-repo
) does not report any problems on my PR.Breaking Change
Does your PR require Flutter developers to manually update their apps to accommodate your change?