Dart Documentationdart.pkg.collection.wrappersUnmodifiableMapView<K, V>

UnmodifiableMapView<K, V> class

An unmodifiable map.

An UnmodifiableMapView contains a Map object and ensures that it does not change. Methods that would change the map, such as addAll and remove, throw an UnsupportedError. Permitted operations defer to the wrapped map.

class UnmodifiableMapView<K, V> extends DelegatingMap<K, V>
                               with UnmodifiableMapMixin<K, V> {
 UnmodifiableMapView(Map<K, V> baseMap) : super(baseMap);
}

Extends

DelegatingMap<K, V> > UnmodifiableMapView<K, V>

Mixins

UnmodifiableMapMixin<K, V>

Constructors

new UnmodifiableMapView(Map<K, V> baseMap) #

Creates a Map instance with the default implementation, LinkedHashMap.

A LinkedHashMap requires the keys to implement compatible operator== and hashCode, and it allows null as a key.

docs inherited from Map<K, V>
UnmodifiableMapView(Map<K, V> baseMap) : super(baseMap);

Properties

final bool isEmpty #

inherited from DelegatingMap

Returns true if there is no key-value pair in the map.

docs inherited from Map<K, V>
bool get isEmpty => _base.isEmpty;

final bool isNotEmpty #

inherited from DelegatingMap

Returns true if there is at least one key-value pair in the map.

docs inherited from Map<K, V>
bool get isNotEmpty => _base.isNotEmpty;

final Iterable<K> keys #

inherited from DelegatingMap

The keys of this.

The returned iterable has efficient length and contains operations, based on length and containsKey of the map.

docs inherited from Map<K, V>
Iterable<K> get keys => _base.keys;

final int length #

inherited from DelegatingMap

The number of key-value pairs in the map.

docs inherited from Map<K, V>
int get length => _base.length;

final Iterable<V> values #

inherited from DelegatingMap

The values of this.

The returned iterable has an efficient length method based on the length of the map.

docs inherited from Map<K, V>
Iterable<V> get values => _base.values;

Operators

V operator [](Object key) #

inherited from DelegatingMap

Returns the value for the given key or null if key is not in the map. Because null values are supported, one should either use containsKey to distinguish between an absent key and a null value, or use the putIfAbsent method.

docs inherited from Map<K, V>
V operator [](Object key) => _base[key];

void operator []=(K key, V value) #

mixed in from UnmodifiableMapMixin<K, V>

Throws an UnsupportedError; operations that change the map are disallowed.

void operator []=(K key, V value) => _throw();

Methods

void addAll(Map<K, V> other) #

mixed in from UnmodifiableMapMixin<K, V>

Throws an UnsupportedError; operations that change the map are disallowed.

void addAll(Map<K, V> other) => _throw();

void clear() #

mixed in from UnmodifiableMapMixin<K, V>

Throws an UnsupportedError; operations that change the map are disallowed.

void clear() => _throw();

bool containsKey(Object key) #

inherited from DelegatingMap

Returns true if this map contains the given key.

docs inherited from Map<K, V>
bool containsKey(Object key) => _base.containsKey(key);

bool containsValue(Object value) #

inherited from DelegatingMap

Returns true if this map contains the given value.

docs inherited from Map<K, V>
bool containsValue(Object value) => _base.containsValue(value);

void forEach(void f(K key, V value)) #

inherited from DelegatingMap

Applies f to each {key, value} pair of the map.

It is an error to add or remove keys from the map during iteration.

docs inherited from Map<K, V>
void forEach(void f(K key, V value)) {
 _base.forEach(f);
}

V putIfAbsent(K key, V ifAbsent()) #

mixed in from UnmodifiableMapMixin<K, V>

Throws an UnsupportedError; operations that change the map are disallowed.

V putIfAbsent(K key, V ifAbsent()) { _throw(); }

V remove(K key) #

mixed in from UnmodifiableMapMixin<K, V>

Throws an UnsupportedError; operations that change the map are disallowed.

V remove(K key) { _throw(); }