join

Concatenates every element into one string, with a separator between them.

String join<A>(String sep, Iterable<A> iterable) // data-first: separator FIRST Future<String> joinAsync<A>(String sep, FxAsyncIterable<A> iterable) String Fx.join([String separator = '']) // chain (sync, inherited from Iterable) Future<String> FxAsync.join([String sep = ',']) // chain (async)

Lecture

join is a terminal operator: it pulls the whole pipeline, calling toString() on each element and stitching the results together with sep in between.

Pay attention to argument order — the top-level, data-first join puts the separator first: join(', ', iterable). That's the FxTS convention (data-first everywhere), and it's the opposite of Dart's own Iterable.join(separator) method, which takes the iterable as the receiver and the separator as its one argument.

That difference bleeds into the chain form in a subtle way: on the sync chain, .join(...) is simply Dart's built-in Iterable.join, whose default separator is '' (empty) when omitted. But FxAsync.join is written explicitly in FxDart and defaults its separator to ',' instead — matching FxTS's own default. Don't assume the two chains behave identically when you skip the argument.

Demo 1 · Basics & the two defaults

Demo 2 · Async, and its different default

Try it yourself

Exercise: join the columns into a single CSV header row, separated by ','.

Related: sort — order elements before joining them · map — format each element before joining · size — the other simple string/count terminal