firstOrNull method

T? firstOrNull([
  1. bool predicate(
    1. T item
    )?
])

Implementation

T? firstOrNull([ bool Function(T item)? predicate ]) {
	Iterable<T> iter = this;
	if (predicate != null) {
		iter = this.where(predicate);
	}

	if (iter.isEmpty) {
		return null;
	}

	return iter.first;
}