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

fxEvolve

Runs selected values through per-key transformation functions, leaving the rest of the Map as-is.

Map<K, Object?> fxEvolve<K>( Map<K, Object? Function(Object? value)> transformations, Map<K, Object?> map)

Lecture

fxEvolve takes a "recipe" map — key to transformation function — and a data map, and produces a new map where every key that appears in the recipe has its value passed through the matching function; every other key is copied through unchanged.

Notice the signature is deliberately loose: both maps are typed with Object? values, mirroring FxTS's dynamically-typed original. That means your transformation functions receive Object? and must cast (v as String, v as int, …) before doing anything type-specific — a small tax for the flexibility of applying different transformations to different value types within a single map. If you know the shape of your data ahead of time and don't need per-key heterogeneity, a plain {...map, 'key': f(map['key'])} spread is often more idiomatic Dart; reach for fxEvolve when the recipe itself is data (e.g. built once and reused across many maps).

Demo 1 · Basics

Demo 2 · Parsing raw string fields

Try it yourself

Exercise: use fxEvolve to double the 'price' field and leave 'title' untouched.

Related: fxProp — read a single value out · fxOmitBy — drop entries instead of transforming them · fxCompactObject — a specialized cleanup pass · fxResolveProps — the async cousin, awaiting instead of transforming