Appearance
MidiInputMap ​
Annotations: @Native.new("MIDIInputMap")
Mixed-in types
Properties ​
entries no setter inherited ​
The map entries of this Map.
Inherited from MapBase.
Implementation
dart
Iterable<MapEntry<K, V>> get entries {
return keys.map((K key) => MapEntry<K, V>(key, this[key] as V));
}hashCode no setter inherited ​
int get hashCodeInherited from Interceptor.
Implementation
dart
int get hashCode => Primitives.objectHashCode(this);isEmpty no setter override ​
bool get isEmptyWhether there is no key/value pair in the map.
Implementation
dart
bool get isEmpty => length == 0;isNotEmpty no setter override ​
bool get isNotEmptyWhether there is at least one key/value pair in the map.
Implementation
dart
bool get isNotEmpty => !isEmpty;keys no setter override ​
The keys of this Map.
The returned iterable has efficient length and contains operations, based on length and containsKey of the map.
The order of iteration is defined by the individual Map implementation, but must be consistent between changes to the map.
Modifying the map while iterating the keys may break the iteration.
Implementation
dart
Iterable<String> get keys {
final keys = <String>[];
forEach((k, v) => keys.add(k));
return keys;
}length no setter override ​
int get lengthThe number of key/value pairs in the map.
Implementation
dart
int get length => JS('int', '#.size', this);runtimeType no setter inherited ​
Type get runtimeTypeInherited from Interceptor.
Implementation
dart
Type get runtimeType =>
getRuntimeTypeOfInterceptorNotArray(getInterceptor(this), this);values no setter override ​
The values of this Map.
The values are iterated in the order of their corresponding keys. This means that iterating keys and values in parallel will provide matching pairs of keys and values.
The returned iterable has an efficient length method based on the length of the map. Its Iterable.contains method is based on == comparison.
Modifying the map while iterating the values may break the iteration.
Implementation
dart
Iterable<Map> get values {
final values = <Map>[];
forEach((k, v) => values.add(v));
return values;
}Methods ​
addAll() override ​
Adds all key/value pairs of other to this map.
If a key of other is already in this map, its value is overwritten.
The operation is equivalent to doing this[key] = value for each key and associated value in other. It iterates over other, which must therefore not change during the iteration.
dart
final planets = <int, String>{1: 'Mercury', 2: 'Earth'};
planets.addAll({5: 'Jupiter', 6: 'Saturn'});
print(planets); // {1: Mercury, 2: Earth, 5: Jupiter, 6: Saturn}Implementation
dart
void addAll(Map<String, dynamic> other) {
throw new UnsupportedError("Not supported");
}addEntries() inherited ​
Adds all key/value pairs of newEntries to this map.
If a key of newEntries is already in this map, the corresponding value is overwritten.
The operation is equivalent to doing this[entry.key] = entry.value for each MapEntry of the iterable.
dart
final planets = <int, String>{1: 'Mercury', 2: 'Venus',
3: 'Earth', 4: 'Mars'};
final gasGiants = <int, String>{5: 'Jupiter', 6: 'Saturn'};
final iceGiants = <int, String>{7: 'Uranus', 8: 'Neptune'};
planets.addEntries(gasGiants.entries);
planets.addEntries(iceGiants.entries);
print(planets);
// {1: Mercury, 2: Venus, 3: Earth, 4: Mars, 5: Jupiter, 6: Saturn,
// 7: Uranus, 8: Neptune}Inherited from MapBase.
Implementation
dart
void addEntries(Iterable<MapEntry<K, V>> newEntries) {
for (var entry in newEntries) {
this[entry.key] = entry.value;
}
}cast() inherited ​
Map<RK, RV> cast<RK, RV>()Provides a view of this map as having RK keys and RV instances, if necessary.
If this map is already a Map<RK, RV>, it is returned unchanged.
If this set contains only keys of type RK and values of type RV, all read operations will work correctly. If any operation exposes a non-RK key or non-RV value, the operation will throw instead.
Entries added to the map must be valid for both a Map<K, V> and a Map<RK, RV>.
Methods which accept Object? as argument, like containsKey, remove and operator [], will pass the argument directly to the this map's method without any checks. That means that you can do mapWithStringKeys.cast<int,int>().remove("a") successfully, even if it looks like it shouldn't have any effect.
Inherited from MapBase.
Implementation
dart
Map<RK, RV> cast<RK, RV>() => Map.castFrom<K, V, RK, RV>(this);clear() override ​
void clear()Removes all entries from the map.
After this, the map is empty.
dart
final planets = <int, String>{1: 'Mercury', 2: 'Venus', 3: 'Earth'};
planets.clear(); // {}Implementation
dart
void clear() {
throw new UnsupportedError("Not supported");
}containsKey() override ​
bool containsKey(dynamic key)Whether this map contains the given key.
Returns true if any of the keys in the map are equal to key according to the equality used by the map.
dart
final moonCount = <String, int>{'Mercury': 0, 'Venus': 0, 'Earth': 1,
'Mars': 2, 'Jupiter': 79, 'Saturn': 82, 'Uranus': 27, 'Neptune': 14};
final containsUranus = moonCount.containsKey('Uranus'); // true
final containsPluto = moonCount.containsKey('Pluto'); // falseImplementation
dart
bool containsKey(dynamic key) => _getItem(key) != null;containsValue() override ​
bool containsValue(dynamic value)Whether this map contains the given value.
Returns true if any of the values in the map are equal to value according to the == operator.
dart
final moonCount = <String, int>{'Mercury': 0, 'Venus': 0, 'Earth': 1,
'Mars': 2, 'Jupiter': 79, 'Saturn': 82, 'Uranus': 27, 'Neptune': 14};
final moons3 = moonCount.containsValue(3); // false
final moons82 = moonCount.containsValue(82); // trueImplementation
dart
bool containsValue(dynamic value) => values.any((e) => e == value);forEach() override ​
void forEach(void Function(String key, dynamic value) f)Applies action to each key/value pair of the map.
Calling action must not add or remove keys from the map.
dart
final planetsByMass = <num, String>{0.81: 'Venus', 1: 'Earth',
0.11: 'Mars', 17.15: 'Neptune'};
planetsByMass.forEach((key, value) {
print('$key: $value');
// 0.81: Venus
// 1: Earth
// 0.11: Mars
// 17.15: Neptune
});Implementation
dart
void forEach(void f(String key, dynamic value)) {
var entries = JS('', '#.entries()', this);
while (true) {
var entry = JS('', '#.next()', entries);
if (JS('bool', '#.done', entry)) return;
f(
JS('String', '#.value[0]', entry),
convertNativeToDart_Dictionary(JS('', '#.value[1]', entry)),
);
}
}map() inherited ​
Returns a new map where all entries of this map are transformed by the given convert function.
Inherited from MapBase.
Implementation
dart
Map<K2, V2> map<K2, V2>(MapEntry<K2, V2> transform(K key, V value)) {
var result = <K2, V2>{};
for (var key in this.keys) {
var entry = transform(key, this[key] as V);
result[entry.key] = entry.value;
}
return result;
}noSuchMethod() inherited ​
dynamic noSuchMethod(Invocation invocation)Invoked when a nonexistent method or property is accessed.
A dynamic member invocation can attempt to call a member which doesn't exist on the receiving object. Example:
dart
dynamic object = 1;
object.add(42); // Statically allowed, run-time errorThis invalid code will invoke the noSuchMethod method of the integer 1 with an Invocation representing the .add(42) call and arguments (which then throws).
Classes can override noSuchMethod to provide custom behavior for such invalid dynamic invocations.
A class with a non-default noSuchMethod invocation can also omit implementations for members of its interface. Example:
dart
class MockList<T> implements List<T> {
noSuchMethod(Invocation invocation) {
log(invocation);
super.noSuchMethod(invocation); // Will throw.
}
}
void main() {
MockList().add(42);
}This code has no compile-time warnings or errors even though the MockList class has no concrete implementation of any of the List interface methods. Calls to List methods are forwarded to noSuchMethod, so this code will log an invocation similar to Invocation.method(#add, [42]) and then throw.
If a value is returned from noSuchMethod, it becomes the result of the original invocation. If the value is not of a type that can be returned by the original invocation, a type error occurs at the invocation.
The default behavior is to throw a NoSuchMethodError.
Inherited from Interceptor.
Implementation
dart
dynamic noSuchMethod(Invocation invocation) {
throw NoSuchMethodError.withInvocation(this, invocation);
}putIfAbsent() override ​
dynamic putIfAbsent(String key, dynamic Function() ifAbsent)Look up the value of key, or add a new entry if it isn't there.
Returns the value associated to key, if there is one. Otherwise calls ifAbsent to get a new value, associates key to that value, and then returns the new value.
That is, if the key is currently in the map, map.putIfAbsent(key, ifAbsent) is equivalent to map[key]. If the key is not currently in the map, it's instead equivalent to map[key] = ifAbsent() (but without any guarantee that the [] and []= operators are actually called to achieve that effect).
dart
final diameters = <num, String>{1.0: 'Earth'};
final otherDiameters = <double, String>{0.383: 'Mercury', 0.949: 'Venus'};
for (final item in otherDiameters.entries) {
diameters.putIfAbsent(item.key, () => item.value);
}
print(diameters); // {1.0: Earth, 0.383: Mercury, 0.949: Venus}
// If the key already exists, the current value is returned.
final result = diameters.putIfAbsent(0.383, () => 'Random');
print(result); // Mercury
print(diameters); // {1.0: Earth, 0.383: Mercury, 0.949: Venus}The ifAbsent function is allowed to modify the map, and if so, it behaves the same as the equivalent map[key] = ifAbsent().
Implementation
dart
dynamic putIfAbsent(String key, dynamic ifAbsent()) {
throw new UnsupportedError("Not supported");
}remove() override ​
String remove(dynamic key)Removes key and its associated value, if present, from the map.
Returns the value associated with key before it was removed. Returns null if key was not in the map.
Note that some maps allow null as a value, so a returned null value doesn't always mean that the key was absent.
dart
final terrestrial = <int, String>{1: 'Mercury', 2: 'Venus', 3: 'Earth'};
final removedValue = terrestrial.remove(2); // Venus
print(terrestrial); // {1: Mercury, 3: Earth}Implementation
dart
String remove(dynamic key) {
throw new UnsupportedError("Not supported");
}removeWhere() inherited ​
Removes all entries of this map that satisfy the given test.
dart
final terrestrial = <int, String>{1: 'Mercury', 2: 'Venus', 3: 'Earth'};
terrestrial.removeWhere((key, value) => value.startsWith('E'));
print(terrestrial); // {1: Mercury, 2: Venus}Inherited from MapBase.
Implementation
dart
void removeWhere(bool test(K key, V value)) {
var keysToRemove = <K>[];
for (var key in keys) {
if (test(key, this[key] as V)) keysToRemove.add(key);
}
for (var key in keysToRemove) {
this.remove(key);
}
}toString() inherited ​
String toString()A string representation of this object.
Some classes have a default textual representation, often paired with a static parse function (like int.parse). These classes will provide the textual representation as their string representation.
Other classes have no meaningful textual representation that a program will care about. Such classes will typically override toString to provide useful information when inspecting the object, mainly for debugging or logging.
Inherited from MapBase.
Implementation
dart
String toString() => mapToString(this);update() inherited ​
dynamic update(
String key,
dynamic Function(dynamic value) update, {
(dynamic Function())? ifAbsent,
})Updates the value for the provided key.
Returns the new value associated with the key.
If the key is present, invokes update with the current value and stores the new value in the map.
If the key is not present and ifAbsent is provided, calls ifAbsent and adds the key with the returned value to the map.
If the key is not present, ifAbsent must be provided.
dart
final planetsFromSun = <int, String>{1: 'Mercury', 2: 'unknown',
3: 'Earth'};
// Update value for known key value 2.
planetsFromSun.update(2, (value) => 'Venus');
print(planetsFromSun); // {1: Mercury, 2: Venus, 3: Earth}
final largestPlanets = <int, String>{1: 'Jupiter', 2: 'Saturn',
3: 'Neptune'};
// Key value 8 is missing from list, add it using [ifAbsent].
largestPlanets.update(8, (value) => 'New', ifAbsent: () => 'Mercury');
print(largestPlanets); // {1: Jupiter, 2: Saturn, 3: Neptune, 8: Mercury}Inherited from MapBase.
Implementation
dart
V update(K key, V update(V value), {V Function()? ifAbsent}) {
if (this.containsKey(key)) {
return this[key] = update(this[key] as V);
}
if (ifAbsent != null) {
return this[key] = ifAbsent();
}
throw ArgumentError.value(key, "key", "Key not in map.");
}updateAll() inherited ​
void updateAll(dynamic Function(String key, dynamic value) update)Updates all values.
Iterates over all entries in the map and updates them with the result of invoking update.
dart
final terrestrial = <int, String>{1: 'Mercury', 2: 'Venus', 3: 'Earth'};
terrestrial.updateAll((key, value) => value.toUpperCase());
print(terrestrial); // {1: MERCURY, 2: VENUS, 3: EARTH}Inherited from MapBase.
Implementation
dart
void updateAll(V update(K key, V value)) {
for (var key in this.keys) {
this[key] = update(key, this[key] as V);
}
}Operators ​
operator ==() inherited ​
The equality operator.
The default behavior for all Objects is to return true if and only if this object and other are the same object.
Override this method to specify a different equality relation on a class. The overriding method must still be an equivalence relation. That is, it must be:
Total: It must return a boolean for all arguments. It should never throw.
Reflexive: For all objects
o,o == omust be true.Symmetric: For all objects
o1ando2,o1 == o2ando2 == o1must either both be true, or both be false.Transitive: For all objects
o1,o2, ando3, ifo1 == o2ando2 == o3are true, theno1 == o3must be true.
The method should also be consistent over time, so whether two objects are equal should only change if at least one of the objects was modified.
If a subclass overrides the equality operator, it should override the hashCode method as well to maintain consistency.
Inherited from Interceptor.
Implementation
dart
bool operator ==(Object other) => identical(this, other);operator override ​
Map<dynamic, dynamic>? operator [](dynamic key)The value for the given key, or null if key is not in the map.
Some maps allow null as a value. For those maps, a lookup using this operator cannot distinguish between a key not being in the map, and the key being there with a null value. Methods like containsKey or putIfAbsent can be used if the distinction is important.
Implementation
dart
Map? operator [](dynamic key) => _getItem(key);operator []=() override ​
void operator []=(String key, dynamic value)Associates the key with the given value.
If the key was already in the map, its associated value is changed. Otherwise the key/value pair is added to the map.
Implementation
dart
void operator []=(String key, dynamic value) {
throw new UnsupportedError("Not supported");
}