findFistWhere<E> function

E? findFistWhere<E>(
  1. List<E> list,
  2. bool test(
    1. E element
    ), {
  3. E? orElse,
})

查找第一个符合条件的内容 可以返回null

Implementation

E? findFistWhere<E>(List<E> list, bool Function(E element) test, {E? orElse}) {
  for (var element in list) {
    if (test(element)) return element;
  }
  return orElse;
}