slice
Returns the values between index start (inclusive) and end (exclusive).
Lecture
slice is a general index window: it yields the elements
whose position falls in [start, end), and omitting
end means "to the end of the source". It's a single
operator that subsumes both drop (via start)
and take (via end) at once.
Watch the argument order in the data-first form — unlike most FxDart
functions, the iterable sits in the middle:
slice(start, iterable, [end]), mirroring FxTS. The chain
form doesn't have this quirk, since the iterable is the receiver:
fx(iterable).slice(start, end). Under the hood
slice is still just walking the source once and counting
indices, so it stays lazy and works fine on an infinite source as long
as you supply an end.
Demo 1 · Basics & argument order
Demo 2 · Async
Try it yourself
Exercise: use slice to grab the window from index 2 up to
(not including) index 5.