lastWhereOrNull method Null safety

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

The last element satisfying test, or null if there are none.

Implementation

T? lastWhereOrNull(bool Function(T element) test) {
  T? result;
  for (var element in this) {
    if (test(element)) result = element;
  }
  return result;
}