isLast method

bool isLast(
  1. T item
)

Return true if the given item is the same (by identity) as the last 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 last item. For example:

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

Implementation

bool isLast(T item) => length > 0 && identical(last, item);