Эта страница ещё не переведена, поэтому показана на английском. Помогите с переводом

prop

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

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

Lecture

On its own, prop('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) => prop('name', m) is a plain unary function you can hand to map, juxt, evolve'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 pluck instead — it's prop already bound to a key and mapped over a collection in one call.

Demo 1 · Basics

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

Try it yourself

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

Related: props — read several keys at once · pluckprop mapped over a whole list · pick — keep several keys as a Map · evolve — transform a value in place