lastWhereOptional method
The last element satisfying test
, or Optional.empty()
if there are none.
Implementation
Optional<T> lastWhereOptional(bool Function(T element) test) {
T? result;
for (var element in this) {
if (test(element)) result = element;
}
return Optional.ofNullable(result);
}