AnyValue class
Cross-language implementation of dynamic object what can hold value of any type. The stored value can be converted to different types using variety of accessor methods.
Example
var value1 = AnyValue('123.456');
value1.getAsInteger(); // Result: 123
value1.getAsString(); // Result: '123.456'
value1.getAsFloat(); // Result: 123.456
See StringConverter See TypeConverter See BooleanConverter See IntegerConverter See LongConverter See DoubleConverter See FloatConverter See DateTimeConverter See ICloneable
- Implemented types
Constructors
- AnyValue([dynamic value])
- Creates a new instance of the object and assigns its value.
-
AnyValue.fromJson(Map<
String, dynamic> json) -
Creates a new instance of the object from json.
factory
Properties
- hashCode → int
-
Gets an object hash code which can be used to optimize storing and searching.
no setteroverride
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
clone(
) → dynamic -
Creates a binary clone of this object.
override
-
equals(
dynamic obj) → bool - Compares this object value to specified specified value. When direct comparison gives negative results it tries to compare values as strings.
-
equalsAsType<
T> (TypeCode type, dynamic obj) → bool - Compares this object value to specified specified value. When direct comparison gives negative results it converts values to type specified by type code and compare them again.
-
fromJson(
Map< String, dynamic> json) → void - Initialize this object from JSON Map object
-
getAsArray(
) → AnyValueArray - Converts object value into an AnyArray or returns empty AnyArray if conversion is not possible.
-
getAsBoolean(
) → bool - Converts object value into a boolean or returns false if conversion is not possible.
-
getAsBooleanWithDefault(
bool defaultValue) → bool - Converts object value into a boolean or returns default value if conversion is not possible.
-
getAsDateTime(
) → DateTime - Converts object value into a DateTime or returns current date if conversion is not possible.
-
getAsDateTimeWithDefault(
DateTime defaultValue) → DateTime - Converts object value into a DateTime or returns default value if conversion is not possible.
-
getAsDouble(
) → double - Converts object value into a double or returns 0 if conversion is not possible.
-
getAsDoubleWithDefault(
double defaultValue) → double - Converts object value into a double or returns default value if conversion is not possible.
-
getAsDuration(
) → Duration - Converts object value into a Duration or returns current date if conversion is not possible.
-
getAsDurationWithDefault(
Duration defaultValue) → Duration - Converts object value into a Duration or returns default value if conversion is not possible.
-
getAsFloat(
) → double - Converts object value into a float or returns 0 if conversion is not possible.
-
getAsFloatWithDefault(
double defaultValue) → double - Converts object value into a float or returns default value if conversion is not possible.
-
getAsInteger(
) → int - Converts object value into an integer or returns 0 if conversion is not possible.
-
getAsIntegerWithDefault(
int defaultValue) → int - Converts object value into a integer or returns default value if conversion is not possible.
-
getAsLong(
) → int - Converts object value into a long or returns 0 if conversion is not possible.
-
getAsLongWithDefault(
int defaultValue) → int - Converts object value into a long or returns default value if conversion is not possible.
-
getAsMap(
) → AnyValueMap - Converts object value into AnyMap or returns empty AnyMap if conversion is not possible.
-
getAsNullableBoolean(
) → bool? - Converts object value into a boolean or returns null if conversion is not possible.
-
getAsNullableDateTime(
) → DateTime? - Converts object value into a DateTime or returns null if conversion is not possible.
-
getAsNullableDouble(
) → double? - Converts object value into a double or returns null if conversion is not possible.
-
getAsNullableDuration(
) → Duration? - Converts object value into a Duration or returns null if conversion is not possible.
-
getAsNullableFloat(
) → double? - Converts object value into a float or returns null if conversion is not possible.
-
getAsNullableInteger(
) → int? - Converts object value into an integer or returns null if conversion is not possible.
-
getAsNullableLong(
) → int? - Converts object value into a long or returns null if conversion is not possible.
-
getAsNullableString(
) → String? - Converts object value into a string or returns null if conversion is not possible.
-
getAsNullableType<
T> (TypeCode type) → T? - Converts object value into a value defined by specied typecode. If conversion is not possible it returns null.
-
getAsObject(
) → dynamic - Gets the value stored in this object without any conversions
-
getAsString(
) → String - Converts object value into a string or returns '' if conversion is not possible.
-
getAsStringWithDefault(
String defaultValue) → String - Converts object value into a string or returns default value if conversion is not possible.
-
getAsType<
T> (TypeCode typeCode) → T - Converts object value into a value defined by specied typecode. If conversion is not possible it returns default value for the specified type.
-
getAsTypeWithDefault<
T> (TypeCode typeCode, T defaultValue) → T - Converts object value into a value defined by specied typecode. If conversion is not possible it returns default value.
-
getTypeCode(
) → TypeCode - Gets type code for the value stored in this object.
-
innerValue(
) → dynamic - Returned inner values in Map object
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
setAsObject(
dynamic value) → void - Sets a new value for this object
-
toJson(
) → Map< String, dynamic> - Returned JSON Map object from values of this object
-
toString(
) → String -
Gets a string representation of the object.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited