takeTo method

Iterable<E> takeTo(
  1. E element
)

Returns the list prefix up to the first occurrence of element. If the element is not found return the whole list.

Implementation

Iterable<E> takeTo(E element) {
  final index = indexOf(element);
  if (index < 0) return getRange(0, length);
  return getRange(0, index);
}