fxProp

Returns the value of a key in a Map, or null when it's missing.

V? fxProp<K, V>(K key, Map<K, V> map)

Lecture

On its own, fxProp('name', user) does exactly what user['name'] already does in Dart — a missing key yields null either way. The reason it exists as a function at all is composability: map[key] is an operator, not a value you can pass around, but (m) => fxProp('name', m) is a plain unary function you can hand to map, fxJuxt, fxEvolve's callbacks, or anywhere else a Function(Map) is expected.

If what you actually want is one field pulled out of a whole list of maps, reach for fxPluck instead — it's fxProp already bound to a key and mapped over a collection in one call.

Demo 1 · Basics

Demo 2 · As a tear-off, vs. fxPluck

Try it yourself

Exercise: use fxProp to read 'theme', or 'light' if it's missing.

Related: fxProps — read several keys at once · fxPluck — fxProp mapped over a whole list · fxPick — keep several keys as a Map · fxEvolve — transform a value in place