firstWhereOrNull method
Tries to find the first element in the iterable that matches the given test.
Returns null if no such element is found.
Example:
var list = [1, 2, 3];
var result = list.firstWhereOrNull((i) => i > 2); // 3
Implementation
T? firstWhereOrNull(bool Function(T) test) {
for (T element in this) {
if (test(element)) {
return element;
}
}
return null;
}