-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Closed
Description
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.
Metadata
Metadata
Assignees
Labels
No labels