toMap<K, V> static method

Map<K, V> toMap<K, V>(
  1. dynamic object, {
  2. dynamic mapKey,
  3. int? listIndex,
  4. Map<K, V>? defaultValue,
  5. ElementConverter<K>? keyConverter,
  6. ElementConverter<V>? valueConverter,
})

Converts object to a strongly-typed Map, optionally transforming keys and values with keyConverter and valueConverter.

JSON strings are decoded before conversion. Throws ConversionException when mapping fails and defaultValue is null.

Implementation

static Map<K, V> toMap<K, V>(
  dynamic object, {
  dynamic mapKey,
  int? listIndex,
  Map<K, V>? defaultValue,
  ElementConverter<K>? keyConverter,
  ElementConverter<V>? valueConverter,
}) => ConvertObjectImpl.toMap<K, V>(
  object,
  mapKey: mapKey,
  listIndex: listIndex,
  defaultValue: defaultValue,
  keyConverter: keyConverter,
  valueConverter: valueConverter,
);