typed<K, V> method Null safety

  1. @Deprecated('Use map.cast<K, V> instead.')
Map<K, V> typed<K, V>(
  1. Map base
)
Deprecated('Use map.cast<K, V> instead.')">@Deprecated('Use map.cast<K, V> instead.')

Creates a wrapper that asserts the types of keys and values in base.

This soundly converts a Map without generic types to a Map<K, V> by asserting that its keys are instances of E and its values are instances of V whenever they're accessed. If they're not, it throws a CastError. Note that even if an operation throws a CastError, it may still mutate the underlying collection.

This forwards all operations to base, so any changes in base will be reflected in this. If base is already a Map<K, V>, it's returned unmodified.

Implementation

@Deprecated('Use map.cast<K, V> instead.')
static Map<K, V> typed<K, V>(Map base) => base.cast<K, V>();