E singleWhere(
bool test(E element)
)

Returns the single element that satisfies test.

Checks all elements to see if test(element) returns true. If exactly one element satisfies test, that element is returned. Otherwise, if there are no matching elements, or if there is more than one matching element, a StateError is thrown.

Source

/**
 * Returns the single element that satisfies [test].
 *
 * Checks all elements to see if `test(element)` returns true.
 * If exactly one element satisfies [test], that element is returned.
 * Otherwise, if there are no matching elements, or if there is more than
 * one matching element, a [StateError] is thrown.
 */
E singleWhere(bool test(E element));