drop function

List drop(
  1. List list, [
  2. int n = 1
])

Creates a slice of list with n elements dropped from the beginning.

drop([1, 2, 3])
// => [2,3]

drop([1, 2, 3], 2)
// => [3]

drop([1, 2, 3], 5)
// => []

drop([1, 2, 3], 0)
// => [1, 2, 3]

Implementation

List drop(List list, [int n = 1]) {
  return list.isEmpty ? [] : slice(list, n < 0 ? 0 : n, list.length);
}