rotate method
Rotates the list left by n positions (negative = right rotation).
[1,2,3,4,5].rotate(2) // [3,4,5,1,2]
Implementation
List<T> rotate(int n) {
if (isEmpty) return [];
final offset = n % length;
if (offset == 0) return [...this];
return [...sublist(offset), ...sublist(0, offset)];
}