本页尚未翻译,因此以英文显示。 参与翻译

dropUntil

Skips values until the predicate matches — the matching element is dropped too — then yields the rest.

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

Lecture

dropUntil is the drop-side counterpart to takeUntilInclusive — and the two treat their matching element in opposite ways. dropWhile stops dropping right before the failing element, keeping it in the output; dropUntil stops at the matching element and discards it along with everything before it. Only elements strictly after the match survive.

Use it when a marker or sentinel needs to disappear along with the prefix it delimits — "everything after the READY line, not including READY itself".

Demo 1 · Basics

Compare with dropWhile: here the matching element (3 / 'STOP') does not appear in the result:

Demo 2 · Async

Try it yourself

Exercise: drop everything up to and including 'READY'.

Related: dropWhile — keeps the matching element · takeUntilInclusive — the take-side counterpart · drop — drop by fixed count