firstBy method

T? firstBy(
  1. bool predicate(
    1. T t
    )
)

Find object on type T that matches criteria.

Implementation

T? firstBy(bool Function(T t) predicate) {
  T? maybeValue;
  forEach((entry) {
    if (predicate.call(entry)) {
      // Don't override the first found value.
      maybeValue = maybeValue ?? entry;
    }
  });

  return maybeValue;
}