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
Comments
I spoke with hixie about this issue, and he thinks we should change the type for |key| to |String|. |
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.
Closed
Closed
Closed
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 |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
The text was updated successfully, but these errors were encountered: