withDefault method

MapWithDefault<K, V> withDefault(
  1. V value
)

Returns a mutable view of this map that responds with the provided default value, when the caller tries to access a non-existent key.

For example:

final map = {'a': 1}.withDefault(42); print(map'z'); // prints '42' print(map.containsKey('z')); // prints 'false'

Implementation

MapWithDefault<K, V> withDefault(V value) => MapWithDefault(this, value);