ensureUniqueKeysForList static method
Wrap each item in a KeyedSubtree whose key is based on the item's existing key or
the sum of its list index and baseIndex
.
Implementation
static List<Widget> ensureUniqueKeysForList(List<Widget> items, {int baseIndex = 0}) {
if (items.isEmpty) {
return items;
}
final List<Widget> itemsWithUniqueKeys = <Widget>[];
int itemIndex = baseIndex;
for (final Widget item in items) {
itemsWithUniqueKeys.add(KeyedSubtreeModifier.wrap(item, itemIndex));
itemIndex += 1;
}
assert(!debugItemsHaveDuplicateKeys(itemsWithUniqueKeys));
return itemsWithUniqueKeys;
}