getOrNull<T> static method

T? getOrNull<T>(
  1. Iterable<T>? items,
  2. int index
)

Implementation

static T? getOrNull<T>(Iterable<T>? items, int index) {
  if (items == null) return null;
  final List<T> list = (items is! List<T>) ? items = [...items] : [...items];
  if (list.length > index) {
    return list[index];
  } else {
    return null;
  }
}