Эта страница ещё не переведена, поэтому показана на английском. Помогите с переводом

takeUntilInclusive

Yields values until the predicate matches — the matching element is included.

Iterable<A> takeUntilInclusive<A>(bool Function(A a) f, Iterable<A> iterable) FxAsyncIterable<A> takeUntilInclusiveAsync<A>(FutureOr<bool> Function(A a) f, FxAsyncIterable<A> iterable) Fx<T> Fx.takeUntilInclusive(bool Function(T a) f) // chain FxAsync<T> FxAsync.takeUntilInclusive(FutureOr<bool> Function(T a) f)

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'.

Related: takeWhile — stops before the match, excludes it · dropUntil — the drop-side counterpart · take — take by count