singleWhereOrNull method
Returns the single element passing the given test
, or null
if element
was not found or more than one element was found.
Implementation
E? singleWhereOrNull(bool Function(E element) test) {
var found = false;
E? single;
for (final element in this) {
if (test(element)) {
if (found) return null;
single = element;
found = true;
}
}
return single;
}