HashMap<K, V>.of constructor Null safety

HashMap<K, V>.of(
  1. Map<K, V> other
)

Creates a HashMap that contains all key/value pairs of other. Example:

final baseMap = <int, String>{1: 'A', 2: 'B', 3: 'C'};
final mapOf = HashMap<num, Object>.of(baseMap);
print(mapOf); // {1: A, 2: B, 3: C}

Implementation

factory HashMap.of(Map<K, V> other) => HashMap<K, V>()..addAll(other);