このページはまだ翻訳されていないため、英語で表示されます。 翻訳に参加する

entries

Yields a Map's (key, value) pairs as records — the entry point for chaining over a Map.

Iterable<(K, V)> entries<K, V>(Map<K, V> map)

Lecture

A Dart Map isn't an Iterable the way a List is, so there's no fx(someMap) directly. entries is the bridge: it yields each key/value pair of the map as a (K, V) record, giving you a plain lazy Iterable you can wrap with fx() and chain like anything else. This mirrors FxTS's entries, which does the same for a JS object.

Because the pairs are Dart records, you can destructure them directly in a for loop — for (final (key, value) in entries(map)) — or access the positional fields .$1 (key) and .$2 (value) inside a map/filter callback when destructuring isn't convenient.

entries is lazy like everything else here, but a Map's entries aren't infinite, so there's rarely a reason to bound it with take — it's more about turning a Map into something chainable than about controlling how much gets pulled.

Demo 1 · Basics

Demo 2 · Chaining over a Map

Wrap entries(map) with fx() to filter and reshape a Map's contents:

Try it yourself

Exercise: turn a Map of scores into "name: PASS/FAIL" strings.

Related: keys — just the keys of a Map · values — just the values of a Map · fromEntries — the inverse: build a Map back from pairs · fx — the chain entries results feed into