singleWhere method Null safety
- @override
- bool test(
- E element
- {E orElse(
Returns the single element that satisfies test
.
Checks elements to see if test(element)
returns true.
If exactly one element satisfies test
, that element is returned.
If more than one matching element is found, throws StateError
.
If no matching element is found, returns the result of orElse
.
If orElse
is omitted, it defaults to throwing a StateError
.
Implementation
@override
E singleWhere(bool Function(E element) test, {E Function()? orElse}) =>
_values.singleWhere(test, orElse: orElse);