Skip to content
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

UI Node key confusion #26

Closed
cpu-chromium opened this issue Jun 12, 2015 · 3 comments
Closed

UI Node key confusion #26

cpu-chromium opened this issue Jun 12, 2015 · 3 comments

Comments

@cpu-chromium
Copy link

UI nodes require a unique key for arrays of homogeneous children. They key is nominally Object but internally it seems to be converted to String. This causes the surprising behavior that custom objects are rejected as keys:

[0612/154234:ERROR:dart_error.cc(20)] Unhandled exception:
Uncaught Error: If multiple non-interchangeable nodes of the same type exist as children
of another node, they must have unique keys.
Duplicate:

The current workaround is to add a custom .toString() method to any custom class used as key

For example

class Cell {
final int posX;
final int posY;
Cell(this.posX, this.posY);
String toString() => 'Cell($posX, $posY)';
}

without the toString() method, it cannot be used as a key.

@abarth
Copy link
Contributor

abarth commented Jun 13, 2015

I spoke with hixie about this issue, and he thinks we should change the type for |key| to |String|.

@abarth
Copy link
Contributor

abarth commented Jun 16, 2015

@abarth abarth closed this as completed Jun 16, 2015
abarth added a commit to flutter/engine that referenced this issue Jul 16, 2015
We need the key to be a String even though we claimed we could support any
Object. Also, clean up some style nits including shortening the |root| getters
on OneChildRenderNodeWrappers.

Fixes flutter/flutter#26.

TBR=ianh@google.com

Review URL: https://codereview.chromium.org/1173293005.
@radensoft radensoft mentioned this issue May 9, 2021
@github-actions
Copy link

github-actions bot commented Sep 7, 2021

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 7, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants