zip
Pairs up elements from two iterables into records, stopping at the shorter one.
Lecture
zip walks two iterables side by side and yields one pair
per step, stopping the moment either input runs out. Where FxTS returns
a TS tuple, FxDart returns a Dart record —
(A, B) — so you destructure results with
.$1/.$2 or pattern matching instead of
array indices. Since Dart has no variadic generics, each arity gets its
own function: zip for two iterables,
zip3 for three.
zipAsync issues both sides' next() calls
before awaiting either — so it pulls the two sources in
parallel per pair rather than sequentially. Zipping two 100ms-per-item
sources still only costs ~100ms per pair, not 200ms.
Demo 1 · Basics
Demo 2 · Async, pulled in parallel per pair
Try it yourself
Exercise: zip names and ages together into
(name, age) records.
zipWith — zip and combine in one step ·
zipWithIndex — zip against a running index ·
transpose — zip an arbitrary number of rows ·
concat — chain instead of pair