cFirstWhere method

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

Get the first item from the iterable that satisfies a condition.

If the iterable is empty or no element satisfies the condition, this method returns null.

Parameters:

  • test: A function that takes an element of the iterable and returns true if the element satisfies the condition.

Implementation

T? cFirstWhere(bool Function(T element) test) {
  final list = where(test);
  return list.isEmpty ? null : list.first;
}