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

UnmodifiableMapMixin<K, V> abstract class

Mixin class that implements a throwing version of all map operations that change the Map.

abstract class UnmodifiableMapMixin<K, V> implements Map<K, V> {
 static void _throw() {
   throw new UnsupportedError("Cannot modify an unmodifiable Map");
 }

 /**
  * Throws an [UnsupportedError];
  * operations that change the map are disallowed.
  */
 void operator []=(K key, V value) => _throw();

 /**
  * Throws an [UnsupportedError];
  * operations that change the map are disallowed.
  */
 V putIfAbsent(K key, V ifAbsent()) { _throw(); }

 /**
  * Throws an [UnsupportedError];
  * operations that change the map are disallowed.
  */
 void addAll(Map<K, V> other) => _throw();

 /**
  * Throws an [UnsupportedError];
  * operations that change the map are disallowed.
  */
 V remove(K key) { _throw(); }

 /**
  * Throws an [UnsupportedError];
  * operations that change the map are disallowed.
  */
 void clear() => _throw();
}

Implements

Map<K, V>

Properties

final bool isEmpty #

inherited from Map

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

bool get isEmpty;

final bool isNotEmpty #

inherited from Map

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

bool get isNotEmpty;

final Iterable<K> keys #

inherited from Map

The keys of this.

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

Iterable<K> get keys;

final int length #

inherited from Map

The number of key-value pairs in the map.

int get length;

final Iterable<V> values #

inherited from Map

The values of this.

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

Iterable<V> get values;

Operators

abstract V operator [](Object key) #

inherited from Map

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.

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

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

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

Methods

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

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

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

void clear() #

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

void clear() => _throw();

abstract bool containsKey(Object key) #

inherited from Map

Returns true if this map contains the given key.

abstract bool containsValue(Object value) #

inherited from Map

Returns true if this map contains the given value.

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

inherited from Map

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

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

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

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

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

V remove(K key) #

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

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