AnyValueMap class
Cross-language implementation of dynamic object map (dictionary) what can hold values of any type. The stored values can be converted to different types using variety of accessor methods.
Example
var value1 = AnyValueMap({ key1: 1, key2: '123.456', key3: '2018-01-01' });
value1.getAsBoolean('key1'); // Result: true
value1.getAsInteger('key2'); // Result: 123
value1.getAsFloat('key2'); // Result: 123.456
value1.getAsDateTime('key3'); // Result: Date(2018,0,1)
See StringConverter See TypeConverter See BooleanConverter See IntegerConverter See LongConverter See DoubleConverter See FloatConverter See DateTimeConverter See ICloneable
- Inheritance
- Object
- MapMixin<
String, dynamic> - MapBase<
String, dynamic> - AnyValueMap
- Implemented types
- Implementers
Constructors
- AnyValueMap([dynamic values ])
- Creates a new instance of the map and assigns its value. [...]
-
AnyValueMap.fromJson(Map<
String, dynamic> json) -
Creates a new instance of the map from JSON. [...]
factory
Properties
-
keys
→ Iterable<
String> -
The keys of this. [...]
read-only, override
-
values
→ Iterable<
String> -
The values of this. [...]
read-only, override
-
entries
→ Iterable<
MapEntry< String, dynamic> > -
The map entries of this.
read-only, inherited
- hashCode → int
-
The hash code for this object. [...]
read-only, inherited
- isEmpty → bool
-
Returns true if there is no key/value pair in the map.
read-only, inherited
- isNotEmpty → bool
-
Returns true if there is at least one key/value pair in the map.
read-only, inherited
- length → int
-
The number of key/value pairs in the map.
read-only, inherited
- runtimeType → Type
-
A representation of the runtime type of the object.
read-only, inherited
Methods
-
append(
dynamic map) → void - Appends new elements to this map. [...]
-
clear(
) → void -
Clears this map by removing all its elements.
override
-
clone(
) → dynamic -
Creates a binary clone of this object. [...]
override
-
fromJson(
Map< String, dynamic> json) → void - Initialize this object from JSON Map object
-
get(
String key) → dynamic - Gets a map element specified by its key. [...]
-
getAsArray(
String key) → AnyValueArray - Converts map element into an AnyValueArray or returns empty AnyValueArray if conversion is not possible. [...]
-
getAsArrayWithDefault(
String key, AnyValueArray defaultValue) → AnyValueArray - Converts map element into an AnyValueArray or returns default value if conversion is not possible. [...]
-
getAsBoolean(
String key) → bool - Converts map element into a boolean or returns false if conversion is not possible. [...]
-
getAsBooleanWithDefault(
String key, bool defaultValue) → bool - Converts map element into a boolean or returns default value if conversion is not possible. [...]
-
getAsDateTime(
String key) → DateTime - Converts map element into a DateTime or returns the current date if conversion is not possible. [...]
-
getAsDateTimeWithDefault(
String key, DateTime defaultValue) → DateTime - Converts map element into a DateTime or returns default value if conversion is not possible. [...]
-
getAsDouble(
String key) → double - Converts map element into a double or returns 0 if conversion is not possible. [...]
-
getAsDoubleWithDefault(
String key, double defaultValue) → double - Converts map element into a double or returns default value if conversion is not possible. [...]
-
getAsDuration(
String key) → Duration - Converts map element into a Duration or returns the current date if conversion is not possible. [...]
-
getAsDurationWithDefault(
String key, Duration defaultValue) → Duration - Converts map element into a Duration or returns default value if conversion is not possible. [...]
-
getAsFloat(
String key) → double - Converts map element into a float or returns 0 if conversion is not possible. [...]
-
getAsFloatWithDefault(
String key, double defaultValue) → double - Converts map element into a flot or returns default value if conversion is not possible. [...]
-
getAsInteger(
String key) → int - Converts map element into an integer or returns 0 if conversion is not possible. [...]
-
getAsIntegerWithDefault(
String key, int defaultValue) → int - Converts map element into an integer or returns default value if conversion is not possible. [...]
-
getAsLong(
String key) → int - Converts map element into a long or returns 0 if conversion is not possible. [...]
-
getAsLongWithDefault(
String key, int defaultValue) → int - Converts map element into a long or returns default value if conversion is not possible. [...]
-
getAsMap(
String key) → AnyValueMap - Converts map element into an AnyValueMap or returns empty AnyValueMap if conversion is not possible. [...]
-
getAsMapWithDefault(
String key, AnyValueMap defaultValue) → AnyValueMap - Converts map element into an AnyValueMap or returns default value if conversion is not possible. [...]
-
getAsNullableArray(
String key) → AnyValueArray - Converts map element into an AnyValueArray or returns null if conversion is not possible. [...]
-
getAsNullableBoolean(
String key) → bool - Converts map element into a boolean or returns null if conversion is not possible. [...]
-
getAsNullableDateTime(
String key) → DateTime - Converts map element into a DateTime or returns null if conversion is not possible. [...]
-
getAsNullableDouble(
String key) → double - Converts map element into a double or returns null if conversion is not possible. [...]
-
getAsNullableDuration(
String key) → Duration - Converts map element into a Duration or returns null if conversion is not possible. [...]
-
getAsNullableFloat(
String key) → double - Converts map element into a float or returns null if conversion is not possible. [...]
-
getAsNullableInteger(
String key) → int - Converts map element into an integer or returns null if conversion is not possible. [...]
-
getAsNullableLong(
String key) → int - Converts map element into a long or returns null if conversion is not possible. [...]
-
getAsNullableMap(
String key) → AnyValueMap - Converts map element into an AnyValueMap or returns null if conversion is not possible. [...]
-
getAsNullableString(
String key) → String - Converts map element into a String or returns null if conversion is not possible. [...]
-
getAsNullabvarype<
T> (TypeCode type, String key) → T - Converts map element into a value defined by specied typecode. If conversion is not possible it returns null. [...]
-
getAsObject(
[String key ]) → dynamic - Gets the value stored in map element without any conversions. When element key is not defined it returns the entire map value. [...]
-
getAsString(
String key) → String - Converts map element into a String or returns '' if conversion is not possible. [...]
-
getAsStringWithDefault(
String key String defaultValue) → String - Converts map element into a String or returns default value if conversion is not possible. [...]
-
getAsType<
T> (TypeCode type, String key) → T - Converts map element into a value defined by specied typecode. If conversion is not possible it returns default value for the specified type. [...]
-
getAsTypeWithDefault<
T> (TypeCode type, String key, T defaultValue) → T - Converts map element into a value defined by specied typecode. If conversion is not possible it returns default value. [...]
-
getAsValue(
String key) → AnyValue - Converts map element into an AnyValue or returns an empty AnyValue if conversion is not possible. [...]
-
getKeys(
) → List< String> - Gets keys of all elements stored in this map. [...]
-
getValue(
) → Map< String, dynamic> - Gets an map with values. [...]
-
innerValue(
) → dynamic - Returned inner values in Map object
-
put(
String key, dynamic value) → void - Puts a new value into map element specified by its key. [...]
-
remove(
dynamic key) → void -
Removes a map element specified by its key [...]
override
-
setAsObject(
dynamic key, [ dynamic value ]) → void - Sets a new value to map element specified by its index. When the index is not defined, it resets the entire map value. This method has double purpose because method overrides are not supported in JavaScript. [...]
-
toJson(
) → Map< String, dynamic> - Returned JSON Map object from values of this object
-
toString(
) → String -
Gets a String representation of the object.
The result is a semicolon-separated list of key-value pairs as
'key1=value1;key2=value2;key=value3' [...]
override
-
addAll(
Map< String, dynamic> other) → void -
Adds all key/value pairs of
other
to this map. [...]inherited -
addEntries(
Iterable< MapEntry< newEntries) → voidString, dynamic> > -
Adds all key/value pairs of
newEntries
to this map. [...]inherited -
cast<
RK, RV> () → Map< RK, RV> -
Provides a view of this map as having
RK
keys andRV
instances, if necessary. [...]inherited -
containsKey(
Object key) → bool -
Returns true if this map contains the given
key
. [...]inherited -
containsValue(
Object value) → bool -
Returns true if this map contains the given
value
. [...]inherited -
forEach(
void action(String key, dynamic value)) → void -
Applies
f
to each key/value pair of the map. [...]inherited -
map<
K2, V2> (MapEntry< K2, V2> transform(String key, dynamic value)) → Map<K2, V2> -
Returns a new map where all entries of this map are transformed by
the given
f
function.inherited -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a non-existent method or property is accessed. [...]
inherited
-
putIfAbsent(
String key, dynamic ifAbsent()) → dynamic -
Look up the value of
key
, or add a new value if it isn't there. [...]inherited -
removeWhere(
bool test(String key, dynamic value)) → void -
Removes all entries of this map that satisfy the given
predicate
.inherited -
update(
String key, dynamic update(dynamic value), { dynamic ifAbsent() }) → dynamic -
Updates the value for the provided
key
. [...]inherited -
updateAll(
dynamic update(String key, dynamic value)) → void -
Updates all values. [...]
inherited
Operators
-
operator [](
dynamic key) → dynamic -
Returns the value for the given
key
or null ifkey
is not in the map. [...]override -
operator []=(
String key, dynamic value) → void -
Associates the
key
with the givenvalue
. [...]override -
operator ==(
dynamic other) → bool -
The equality operator. [...]
inherited
Static Methods
-
fromMaps(
List maps) → AnyValueMap - Creates a new AnyValueMap by merging two or more maps. Maps defined later in the list override values from previously defined maps. [...]
-
fromTuples(
List tuples) → AnyValueMap - Creates a new AnyValueMap from a list of key-value pairs called tuples. [...]
-
fromTuplesArray(
List tuples) → AnyValueMap - Creates a new AnyValueMap from a list of key-value pairs called tuples. The method is similar to fromTuples but tuples are passed as array instead of parameters. [...]
-
fromValue(
dynamic value) → AnyValueMap - Converts specified value into AnyValueMap. [...]