firstNonNull<T> function

T? firstNonNull<T>(
  1. Iterable<T?> list
)

Tries a list of nullable Ts until one is not null. Returns null if no actual value is found.

Implementation

T? firstNonNull<T>(Iterable<T?> list) {
  for (final item in list) {
    if (item != null) {
      return item;
    }
  }
  return null;
}