keys
The keys of a Map, as a plain lazy Iterable — ready to wrap in fx() and chain.
Lecture
keys(map) is a thin, FxTS-flavored wrapper around Dart's
own map.keys — it exists mainly so the object-function
vocabulary (entries, keys, values)
reads consistently and slots straight into fx(). Dart's
Map.keys is already a lazy view, so keys
doesn't add any extra buffering — it just hands you the same lazy
Iterable<K>.
Reach for it when you want to filter, transform, or collect a Map's key
set using the rest of the chain vocabulary, rather than reaching for
.where()/.toList() on map.keys
directly — the two are equivalent, but fx(keys(map)) reads
naturally next to fx(values(map)) and
fx(entries(map)).
If you need the keys and values together, use
entries instead — pulling keys and
values separately does not guarantee they line up if the
underlying map were mutated between the two calls.
Demo 1 · Basics
Demo 2 · Filtering a Map by its keys
Try it yourself
Exercise: use keys and sort to get an
alphabetically sorted list of item names.