AttributeMap class
A map of attribute key-value pairs with support for explicit data types, for use with "attributes" parameters in various methods.
For precise control on the data type of a value, an AttributeType can be explicitly specified when setting a value using the set method, or it can be changed later using the setTypeFor method. This is necessary when an attribute needs to have a specific type that is not available natively in Dart; e.g., AttributeType.int32 or AttributeType.float32.
If the type is not explicitly set, it will be inferred from the Dart type of the value; e.g., integers to AttributeType.int64, and doubles to AttributeType.float64.
Keys are case-insensitive strings.
A shorthand syntax is available. Instead of providing a value directly, a map with a single entry can be provided, where the key is the desired AttributeType and the value is the actual value. For example:
final attributes = AttributeMap({
population: {AttributeType.int32: 12345},
});
attributes['elevation'] = {AttributeType.float32: 123.45};
This shorthand syntax can also be used when passing a bare Map<CaseInsensitiveString, dynamic> to any method that takes an "attributes" parameter.
- Inheritance
-
- Object
- MapBase<
CaseInsensitiveString, dynamic> - AttributeMap
Constructors
-
AttributeMap([Map<
CaseInsensitiveString, dynamic> attributes = const {}]) -
Creates an empty AttributeMap, or initializes it with the given
attributes.
Properties
-
entries
→ Iterable<
MapEntry< CaseInsensitiveString, dynamic> > -
The map entries of this Map.
no setteroverride
- hashCode → int
-
The hash code for this object.
no setterinherited
- isEmpty → bool
-
Whether there is no key/value pair in the map.
no setteroverride
- isNotEmpty → bool
-
Whether there is at least one key/value pair in the map.
no setteroverride
-
keys
→ Iterable<
CaseInsensitiveString> -
The keys of this Map.
no setteroverride
- length → int
-
The number of key/value pairs in the map.
no setteroverride
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- values → Iterable
-
The values of this Map.
no setteroverride
Methods
-
addAll(
Map< CaseInsensitiveString, dynamic> other) → void -
Adds all key/value pairs of
otherto this map.inherited -
addEntries(
Iterable< MapEntry< newEntries) → voidCaseInsensitiveString, dynamic> > -
Adds all key/value pairs of
newEntriesto this map.inherited -
cast<
RK, RV> () → Map< RK, RV> -
Provides a view of this map as having
RKkeys andRVinstances, if necessary.inherited -
clear(
) → void -
Removes all entries from the map.
override
-
containsKey(
Object? key) → bool -
Whether this map contains the given
key.override -
containsValue(
Object? value) → bool -
Whether this map contains the given
value.inherited -
forEach(
void action(CaseInsensitiveString key, dynamic value)) → void -
Applies
actionto each key/value pair of the map.inherited -
map<
K2, V2> (MapEntry< K2, V2> transform(CaseInsensitiveString key, dynamic value)) → Map<K2, V2> -
Returns a new map where all entries of this map are transformed by
the given
convertfunction.inherited -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
putIfAbsent(
CaseInsensitiveString key, dynamic ifAbsent()) → dynamic -
Look up the value of
key, or add a new entry if it isn't there.inherited -
remove(
Object? key) → dynamic -
Removes
keyand its associated value, if present, from the map.override -
removeWhere(
bool test(CaseInsensitiveString key, dynamic value)) → void -
Removes all entries of this map that satisfy the given
test.inherited -
set(
{required CaseInsensitiveString key, required dynamic value, AttributeType type = AttributeType.variant}) → void -
Associates the
keywith the givenvalue, optionally specifying an explicittype. -
setTypeFor(
{required CaseInsensitiveString key, required AttributeType type}) → void -
Changes the type of the value associated with the given
keytotype. The key must already exist in the map. -
toString(
) → String -
A string representation of this object.
inherited
-
typeFor(
{required CaseInsensitiveString key}) → AttributeType -
Returns the AttributeType of the value associated with the given
key. The key must already exist in the map. -
update(
CaseInsensitiveString key, dynamic update(dynamic value), {dynamic ifAbsent()?}) → dynamic -
Updates the value for the provided
key.inherited -
updateAll(
dynamic update(CaseInsensitiveString key, dynamic value)) → void -
Updates all values.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
-
operator [](
Object? key) → dynamic -
The value for the given
key, ornullifkeyis not in the map.override -
operator []=(
CaseInsensitiveString key, dynamic value) → void -
Associates the
keywith the givenvalue.override