selectFirst<T> static method

List<T> selectFirst<T>(
  1. List<T> items, {
  2. int count = 1,
})

Always select first item safely.

Implementation

static List<T> selectFirst<T>(List<T> items, {int count = 1}) {
  if (items.isEmpty) return [];
  return items.take(count.clamp(1, items.length)).toList();
}