unjsifyMapProp<K, V> function

Map<K, V>? unjsifyMapProp<K, V>(
  1. JsMap? value
)

Returns value converted to a Dart map and Map.casted to the provided generics, or null if value is null.

For use in JS component prop getters where the component expects a JS object, but typing the getter/setter as a Dart Map is more convenient to the consumer reading/writing the props.

Should be used alongside jsifyMapProp.

For more information on why this conversion is done in the getter/setter, see documentation around Dart wrapper component prop conversion issues. FIXME CPLAT-15060 add reference/link to documentation

Implementation

Map<K, V>? unjsifyMapProp<K, V>(JsMap? value) {
  if (value == null) return null;
  // Don't deep unconvert so that JS values don't get converted incorrectly to Maps. See jsifyMapProp for more information.
  return JsBackedMap.backedBy(value).cast();
}