find<T> function

T? find<T>(
  1. List<T?> list,
  2. dynamic iteratee
)

Iterates over elements of collection, returning the first element predicate returns truthy for. The predicate is invoked with the value of the current item. Arguments

  • list (List): The collection to inspect.
  • iteratee (dynamic): The iteratee invoked per iteration.

Returns (T?): Returns the matched element, else null.

Implementation

T? find<T>(List<T?> list, dynamic iteratee) {
  try {
    return list.firstWhere((element) => evaluatePredicate(iteratee, element));
  } catch (_) {
    return null;
  }
}