lastWhereOrNull method

T? lastWhereOrNull(
  1. bool test(
    1. T element
    )
)

Implementation

T? lastWhereOrNull(bool Function(T element) test) {
  late T result;
  bool foundMatching = false;
  for (T element in this) {
    if (test(element)) {
      result = element;
      foundMatching = true;
    }
  }
  if (foundMatching) return result;
  return null;
}