lastWhereOrNull method

T? lastWhereOrNull(
  1. ConditionTester<T> test
)

Returns the last element that satisfies the predicate or null if none match.

Parameters

  • test: The predicate to check

Returns

  • The last element that satisfies the predicate or null if none match

Implementation

T? lastWhereOrNull(ConditionTester<T> test) {
  for (var element in toList().reversed) {
    if (test(element)) return element;
  }
  return null;
}