isFirst method

bool isFirst(
  1. T item
)

Return true if the given item is the same (by identity) as the first iterable item. If this iterable is empty, always return null. This is useful for non-indexed loops where you need to know when you have the first item. For example:

for (student in students) {
   if (!children.isFirst(student) result.add(Divider());
   result.add(Text(student.name));
}

Implementation

bool isFirst(T item) => length > 0 && identical(first, item);