свойство single
переопределение
Проверяет, что эта итерируемая последовательность содержит только один элемент, и возвращает этот элемент.
Вызывает исключение StateError, если this пуста или содержит более одного элемента.
Реализация
E get single {
if (length > 1) throw IterableElementError.tooMany();
Iterator<E> it = iterator;
if (!it.moveNext()) throw IterableElementError.noElement();
E result = it.current;
return result;
}
© 2012 the Dart project authors
Licensed under the BSD 3-Clause "New" or "Revised" License.
https://api.dart.dev/stable/2.19.6/dart-collection/SetMixin/single.html