decodeMapOrNull<K, V> method

  1. @override
Map<K, V>? decodeMapOrNull<K, V>({
  1. Decodable<K>? keyUsing,
  2. Decodable<V>? valueUsing,
})
override

Decodes the data as a nullable map of key-value pairs.

Optionally takes Decodables to decode the keys and values of the map.

Implementation

@override
Map<K, V>? decodeMapOrNull<K, V>({Decodable<K>? keyUsing, Decodable<V>? valueUsing}) {
  if (_value == null) return null;
  try {
    return _decodeMap(_value as Map, keyUsing, valueUsing);
  } on TypeError {
    throw CodableException.unexpectedType(expected: 'Map<$K, $V>?', actual: '${_value.runtimeType}', data: _value);
  }
}