KeyedSubtree.wrap(Widget child, int childIndex)

Creates a KeyedSubtree for child with a key that's based on the child's existing key or childIndex.

Source

factory KeyedSubtree.wrap(Widget child, int childIndex) {
  Key key = child.key != null ? new ValueKey<Key>(child.key) : new ValueKey<int>(childIndex);
  return new KeyedSubtree(key: key, child: child);
}