shift<T> function

void shift<T>(
  1. List<T> l,
  2. T elem, [
  3. int? n
])

adds the elem to the end of l. if n is given the first element is popped, if the list is longer than n

Implementation

void shift<T>(List<T> l, T elem, [int? n]) {
  l.add(elem);
  if (n != null && l.length > n) l.removeAt(0);
}