safeGetMap<T, V> method

Map<T, V>? safeGetMap<T, V>(
  1. dynamic key
)

Implementation

Map<T, V>? safeGetMap<T, V>(dynamic key) {
  var value = this[key];
  if (value is Map) {
    if (value.isEmpty) {
      return <T, V>{};
    }
    var realMap = <T, V>{};

    value.forEach((key, value) {
      if (key is T && value is V) {
        realMap[key] = value;
      }
    });
    return realMap;
  } else {
    return null;
  }
}