slice method

Set<E> slice(
  1. int start, [
  2. int? end
])

Returns a new set with elements at the specified indices.

Example:

final set = {10, 20, 30, 40, 50};
print(set.slice(1, 3)); // {20, 30}

Implementation

Set<E> slice(int start, [int? end]) {
  final list = toList();
  end ??= list.length;
  return Set.from(list.sublist(start, end));
}