fxSplit
Splits an iterable of single-character strings on a separator character.
Lecture
fxSplit is a direct port of FxTS's character-wise
fxSplit, and that shows in its signature: it doesn't take a
String at all — it takes an Iterable<String>
of single characters, and walks it one character at a time, accumulating
a piece until it sees one equal to sep. In Dart, the
idiomatic way to get that character iterable is
myString.split('') (Dart's own String.split
with an empty pattern breaks a string into its individual characters).
A trailing separator produces a trailing empty string in the output,
matching FxTS's behavior — 'a,b,' splits into
('a', 'b', ''), not just ('a', 'b'). There's no
Fx chain form for fxSplit; call the top-level
function (or fxSplitAsync) directly.
Demo 1 · Basics
Demo 2 · Async
Try it yourself
Exercise: use fxSplit to break csv into color
names on '|'.
chunk — group by fixed size instead of separator ·
unicodeToList — get a proper character array (grapheme-aware) ·
join — the inverse operation