dropLast method

  1. @useResult
List<T> dropLast(
  1. int n
)

All but the last n elements.

Implementation

@useResult
List<T> dropLast(int n) {
  final List<T> list = toList();
  if (n <= 0) return list;
  if (n >= list.length) return <T>[];
  return list.sublist(0, list.length - n);
}