takeUntilInclusive
Yields values until the predicate matches — the matching element is included.
Lecture
takeUntilInclusive is takeWhile's close cousin,
with one deliberate difference: it yields the element that made the
predicate true, then stops. takeWhile stops
before the failing element; takeUntilInclusive
stops after the matching one. Reach for it whenever the
matching element itself is part of the answer — "read the log up to and
including the first error", "collect steps up to and including the
terminator".
FxTS originally named this takeUntil; FxDart keeps
takeUntil (and takeUntilAsync) around as a
@Deprecated alias for source parity, but new code should
call takeUntilInclusive directly.
Demo 1 · Basics
Demo 2 · Async
Try it yourself
Exercise: take the log lines up to and including the first
'ERROR'.