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
Properties
final bool isEmpty #
Returns true if there is no key-value pair in the map.
bool get isEmpty;
final bool isNotEmpty #
Returns true if there is at least one key-value pair in the map.
bool get isNotEmpty;
Operators
abstract V operator [](Object key) #
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) #
Returns true if this map contains the given key.
abstract bool containsValue(Object value) #
Returns true if this map contains the given value.
abstract void forEach(void f(K key, V value)) #
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(); }