objectId method
Object id for the element at index, or for its key when it has one. Ids of a layer start with
'<layerId>/' so that taps come back to it.
Without a key: '<layerId>/<index>'. A ValueKey<String>: '<layerId>/k:<value>'; a ValueKey of a number or
a bool: '<layerId>/k<type>:<value>'. Any other key (ObjectKey, UniqueKey, a ValueKey of an object) is
compared with ==, as Flutter compares keys, and gets '<layerId>/k#<n>'; such an id is kept while the key is
asked for at least once between two syncs.
Implementation
String objectId(Key? key, int index) {
if (key == null) return '$layerId/$index';
if (key is ValueKey) {
switch (key.value) {
case final String value:
return '$layerId/k:$value';
case final num value:
return '$layerId/k${value.runtimeType}:$value';
case final bool value:
return '$layerId/kbool:$value';
}
}
final id = _keyIds[key] ??= _previousKeyIds[key] ?? _nextKeyId++;
return '$layerId/k#$id';
}