firstWhereOrNull method
Returns the first element for which the return value of test
is true
.
Null is returned if there is no element for which the return value of test
is true
.
test
の返り値がtrue
になる場合の最初の要素を返します。
test
の返り値がtrue
になる要素がない場合はNullが返されます。
Implementation
T? firstWhereOrNull(bool Function(T item) test) {
if (isEmpty) {
return null;
}
for (final element in this) {
if (test(element)) {
return element;
}
}
return null;
}