-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Fixed AnimatedSwitcher chain produced duplicates #106962
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
Fixed AnimatedSwitcher chain produced duplicates #106962
Conversation
| Widget build(BuildContext context) { | ||
| _rebuildOutgoingWidgetsIfNeeded(); | ||
| return widget.layoutBuilder(_currentEntry?.transition, _outgoingWidgets!); | ||
| return widget.layoutBuilder(_currentEntry?.transition, _outgoingWidgets!.where((Widget outgoing) => outgoing.key != _currentEntry?.transition.key).toSet().toList()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does this look like? Does the existing one just disappear to be replaced by the new one?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. If we were to display both versions simultaneously then we would have the issue with duplicate keys. The duplicate keys issue seems to not only be a problem with the LayoutIds but also locally for the AnimatedSwitcher.
gspencergoog
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This reverts commit 0d3cc92.
* Fixed AnimatedSwitcher chain produced duplicates * Fixed issue with global keys being copied * trailing whitespace * removed unused dependencies * Fixed dependency loop
)" (flutter#107318) This reverts commit 0d3cc92.

When the child of an AnimatedSwitcher went through rapid changes, there were times where the same widget would be in the display chain many times. For example if the AnimatedSwitcher's child goes from A->B->A then B is displayed once and A is displayed twice. This did not mesh so well when A was given a key as duplicate local keys are disallowed and this would cause problems with the rendering of AnimatedSwitcher.
Pre-launch Checklist
///).