tryMap<K2, V2> method

Map<K2, V2>? tryMap<K2, V2>(
  1. K key
)

Returns the Map<K2, V2> value for key, or null if absent or not a Map<K2, V2>.

Implementation

Map<K2, V2>? tryMap<K2, V2>(K key) {
  final value = this[key];
  if (value is! Map) return null;
  try {
    return value.cast<K2, V2>();
  } catch (_) {
    return null;
  }
}