singleWhereOrNull method
Returns the single matching element, or null if zero or multiple match.
Implementation
T? singleWhereOrNull(bool Function(T element) test) {
T? matched;
var found = false;
for (final element in this) {
if (!test(element)) continue;
if (found) return null;
matched = element;
found = true;
}
return matched;
}