Asserts if the given list of items contains any duplicate non-null keys.
To invoke this function, use the following pattern:
assert(!debugItemsHaveDuplicateKeys(items));
For a version of this function specifically intended for parents checking their children lists, see debugChildrenHaveDuplicateKeys.
Does nothing if asserts are disabled. Always returns true.
Source
bool debugItemsHaveDuplicateKeys(Iterable<Widget> items) { assert(() { final Key nonUniqueKey = _firstNonUniqueKey(items); if (nonUniqueKey != null) throw new FlutterError('Duplicate key found: $nonUniqueKey.'); return true; }); return false; }