Esta página ainda não foi traduzida, por isso é exibida em inglês. Ajude a traduzir

fxFromEntries

Builds a Map from an iterable of (key, value) records.

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

Lecture

This section ports FxTS's object utilities, and the first thing to understand is the mapping: TypeScript's plain objects become Dart Maps throughout, and TS's [key, value] entry tuples become Dart (K, V) records. fxFromEntries is the constructor side of that: give it any iterable of records and it folds them into a Map, last-write-wins on duplicate keys — exactly like building the map by hand with a loop.

It's the natural partner of fxEntries (which does the reverse: Map → records) and pairs nicely with zip, which turns two parallel lists into exactly the record shape fxFromEntries wants.

Demo 1 · Basics

Demo 2 · Duplicate keys, and round-tripping with fxEntries

Try it yourself

Exercise: use fxFromEntries to turn pairs into a Map.

Related: fxEntries — the reverse direction · zip — build entries from two parallel lists · fxOmit — drop keys from the resulting Map · fxPick — keep only some keys