AnyValueArray class
Cross-language implementation of dynamic object array what can hold values of any type. The stored values can be converted to different types using variety of accessor methods.
Example
var value1 = AnyValueArray([1, '123.456', '2018-01-01']);
value1.getAsBoolean(0); // Result: true
value1.getAsInteger(1); // Result: 123
value1.getAsFloat(1); // Result: 123.456
value1.getAsDateTime(2); // 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
- ListBase
- AnyValueArray
- Implemented types
Constructors
- AnyValueArray([Iterable values ])
- Creates a new instance of the array and assigns its value. [...]
-
AnyValueArray.fromJson(Map<
String, dynamic> json) -
Creates a new instance of the array from JSON. [...]
factory
Properties
- length ↔ int
-
Returns the number of objects in this list. [...]
read / write, override
- first ↔ dynamic
-
Returns the first element. [...]
read / write, inherited
- hashCode → int
-
The hash code for this object. [...]
read-only, inherited
- isEmpty → bool
-
Returns
true
if there are no elements in this collection. [...]read-only, inherited - isNotEmpty → bool
-
Returns true if there is at least one element in this collection. [...]
read-only, inherited
- iterator → Iterator
-
Returns a new
Iterator
that allows iterating the elements of thisIterable
. [...]read-only, inherited - last ↔ dynamic
-
Returns the last element. [...]
read / write, inherited
- reversed → Iterable
-
Returns an
Iterable
of the objects in this list in reverse order.read-only, inherited - runtimeType → Type
-
A representation of the runtime type of the object.
read-only, inherited
- single → dynamic
-
Checks that this iterable has only one element, and returns that element. [...]
read-only, inherited
Methods
-
append(
dynamic elements) → void - Appends new elements to this array. [...]
-
clear(
) → void -
Clears this array by removing all its elements.
override
-
clone(
) → dynamic -
Creates a binary clone of this object. [...]
override
-
contains(
dynamic value) → bool -
Checks if this array contains a value.
The check uses direct comparison between elements and the specified value. [...]
override
-
containsAsType<
T> (TypeCode typeCode, dynamic value) → bool - Checks if this array contains a value. The check before comparison converts elements and the value to type specified by type code. [...]
-
fromJson(
Map< String, dynamic> json) → void - Initialize this object from JSON Map object
-
get(
int index) → dynamic - Gets an array element specified by its index. [...]
-
getAsArray(
int index) → AnyValueArray - Converts array element into an AnyValueArray or returns empty AnyValueArray if conversion is not possible. [...]
-
getAsArrayWithDefault(
int index, AnyValueArray defaultValue) → AnyValueArray - Converts array element into an AnyValueArray or returns default value if conversion is not possible. [...]
-
getAsBoolean(
int index) → bool - Converts array element into a boolean or returns false if conversion is not possible. [...]
-
getAsBooleanWithDefault(
int index, bool defaultValue) → bool - Converts array element into a boolean or returns default value if conversion is not possible. [...]
-
getAsDateTime(
int index) → DateTime - Converts array element into a DateTime or returns the current date if conversion is not possible. [...]
-
getAsDateTimeWithDefault(
int index, DateTime defaultValue) → DateTime - Converts array element into a DateTime or returns default value if conversion is not possible. [...]
-
getAsDouble(
dynamic index) → double - Converts array element into a double or returns 0 if conversion is not possible. [...]
-
getAsDoubleWithDefault(
int index, double defaultValue) → double - Converts array element into a double or returns default value if conversion is not possible. [...]
-
getAsDuration(
int index) → Duration - Converts array element into a Duration or returns the current date if conversion is not possible. [...]
-
getAsDurationWithDefault(
int index, Duration defaultValue) → Duration - Converts array element into a Duration or returns default value if conversion is not possible. [...]
-
getAsFloat(
int index) → double - Converts array element into a float or returns 0 if conversion is not possible. [...]
-
getAsFloatWithDefault(
int index, double defaultValue) → double - Converts array element into a float or returns default value if conversion is not possible. [...]
-
getAsInteger(
int index) → int - Converts array element into an integer or returns 0 if conversion is not possible. [...]
-
getAsIntegerWithDefault(
int index int defaultValue) → int - Converts array element into an integer or returns default value if conversion is not possible. [...]
-
getAsLong(
int index) → int - Converts array element into a long or returns 0 if conversion is not possible. [...]
-
getAsLongWithDefault(
int index int defaultValue) → int - Converts array element into a long or returns default value if conversion is not possible. [...]
-
getAsMap(
int index) → AnyValueMap - Converts array element into an AnyValueMap or returns empty AnyValueMap if conversion is not possible. [...]
-
getAsMapWithDefault(
int index, AnyValueMap defaultValue) → AnyValueMap - Converts array element into an AnyValueMap or returns default value if conversion is not possible. [...]
-
getAsNullableArray(
int index) → AnyValueArray - Converts array element into an AnyValueArray or returns null if conversion is not possible. [...]
-
getAsNullableBoolean(
int index) → bool - Converts array element into a boolean or returns null if conversion is not possible. [...]
-
getAsNullableDateTime(
int index) → DateTime - Converts array element into a DateTime or returns null if conversion is not possible. [...]
-
getAsNullableDouble(
int index) → double - Converts array element into a double or returns null if conversion is not possible. [...]
-
getAsNullableDuration(
int index) → Duration - Converts array element into a Duration or returns null if conversion is not possible. [...]
-
getAsNullableFloat(
int index) → double - Converts array element into a float or returns null if conversion is not possible. [...]
-
getAsNullableInteger(
int index) → int - Converts array element into an integer or returns null if conversion is not possible. [...]
-
getAsNullableLong(
int index) → int - Converts array element into a long or returns null if conversion is not possible. [...]
-
getAsNullableMap(
int index) → AnyValueMap - Converts array element into an AnyValueMap or returns null if conversion is not possible. [...]
-
getAsNullableString(
int index) → String - Converts array element into a string or returns null if conversion is not possible. [...]
-
getAsNullableType<
T> (TypeCode type, int index) → T - Converts array element into a value defined by specied typecode. If conversion is not possible it returns null. [...]
-
getAsObject(
[int index ]) → dynamic - Gets the value stored in array element without any conversions. When element index is not defined it returns the entire array value. [...]
-
getAsString(
int index) → String - Converts array element into a string or returns '' if conversion is not possible. [...]
-
getAsStringWithDefault(
int index, String defaultValue) → String - Converts array element into a string or returns default value if conversion is not possible. [...]
-
getAsType<
T> (TypeCode type, int index) → T - Converts array 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, int index, T defaultValue) → T - Converts array element into a value defined by specied typecode. If conversion is not possible it returns default value. [...]
-
getAsValue(
int index) → AnyValue - Converts array element into an AnyValue or returns an empty AnyValue if conversion is not possible. [...]
-
getValue(
) → List - Gets an array with values. [...]
-
innerValue(
) → dynamic - Returned inner values in Map object
-
put(
int index, dynamic value) → void - Puts a new value into array element specified by its index. [...]
-
setAsObject(
dynamic index dynamic value) → void - Sets a new value to array element specified by its index. When the index is not defined, it resets the entire array 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 comma-separated list of string representations of individual elements as
'value1,value2,value3' [...]
override
-
add(
dynamic element) → void -
Adds
value
to the end of this list, extending the length by one. [...]inherited -
addAll(
Iterable iterable) → void -
Appends all objects of
iterable
to the end of this list. [...]inherited -
any(
bool test(dynamic element)) → bool -
Checks whether any element of this iterable satisfies
test
. [...]inherited -
asMap(
) → Map< int, dynamic> -
Returns an unmodifiable
Map
view ofthis
. [...]inherited -
cast<
R> () → List< R> -
Returns a view of this list as a list of
R
instances. [...]inherited -
elementAt(
int index) → dynamic -
Returns the
index
th element. [...]inherited -
every(
bool test(dynamic element)) → bool -
Checks whether every element of this iterable satisfies
test
. [...]inherited -
expand<
T> (Iterable< T> f(dynamic element)) → Iterable<T> -
Expands each element of this
Iterable
into zero or more elements. [...]inherited -
fillRange(
int start, [ int end, [ dynamic fill ]) → void -
Sets the objects in the range
start
inclusive toend
exclusive to the givenfillValue
. [...]inherited -
firstWhere(
bool test(dynamic element), { dynamic orElse() }) → dynamic -
Returns the first element that satisfies the given predicate
test
. [...]inherited -
fold<
T> (T initialValue, T combine(T previousValue, dynamic element)) → T -
Reduces a collection to a single value by iteratively combining each
element of the collection with an existing value [...]
inherited
-
followedBy(
Iterable other) → Iterable -
Returns the lazy concatentation of this iterable and
other
. [...]inherited -
forEach(
void action(dynamic element)) → void -
Applies the function
f
to each element of this collection in iteration order.inherited -
getRange(
int start int end) → Iterable -
Returns an
Iterable
that iterates over the objects in the rangestart
inclusive toend
exclusive. [...]inherited -
indexOf(
Object element, [ int start = 0 ]) → int -
Returns the first index of
element
in this list. [...]inherited -
indexWhere(
bool test(dynamic element), [ int start = 0 ]) → int -
Returns the first index in the list that satisfies the provided
test
. [...]inherited -
insert(
int index, dynamic element) → void -
Inserts the object at position
index
in this list. [...]inherited -
insertAll(
int index, Iterable iterable) → void -
Inserts all objects of
iterable
at positionindex
in this list. [...]inherited -
join(
[String separator = "" ]) → String -
Converts each element to a
String
and concatenates the strings. [...]inherited -
lastIndexOf(
Object element, [ int start ]) → int -
Returns the last index of
element
in this list. [...]inherited -
lastIndexWhere(
bool test(dynamic element), [ int start ]) → int -
Returns the last index in the list that satisfies the provided
test
. [...]inherited -
lastWhere(
bool test(dynamic element), { dynamic orElse() }) → dynamic -
Returns the last element that satisfies the given predicate
test
. [...]inherited -
map<
T> (T f(dynamic element)) → Iterable< T> -
Returns a new lazy
Iterable
with elements that are created by callingf
on each element of thisIterable
in iteration order. [...]inherited -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a non-existent method or property is accessed. [...]
inherited
-
reduce(
dynamic combine(dynamic previousValue dynamic element)) → dynamic -
Reduces a collection to a single value by iteratively combining elements
of the collection using the provided function. [...]
inherited
-
remove(
Object element) → bool -
Removes the first occurrence of
value
from this list. [...]inherited -
removeAt(
int index) → dynamic -
Removes the object at position
index
from this list. [...]inherited -
removeLast(
) → dynamic -
Pops and returns the last object in this list. [...]
inherited
-
removeRange(
int start int end) → void -
Removes the objects in the range
start
inclusive toend
exclusive. [...]inherited -
removeWhere(
bool test(dynamic element)) → void -
Removes all objects from this list that satisfy
test
. [...]inherited -
replaceRange(
int start, int end, Iterable newContents) → void -
Removes the objects in the range
start
inclusive toend
exclusive and inserts the contents ofreplacement
in its place. [...]inherited -
retainWhere(
bool test(dynamic element)) → void -
Removes all objects from this list that fail to satisfy
test
. [...]inherited -
setAll(
int index, Iterable iterable) → void -
Overwrites objects of
this
with the objects ofiterable
, starting at positionindex
in this list. [...]inherited -
setRange(
int start, int end, Iterable iterable, [ int skipCount = 0 ]) → void -
Copies the objects of
iterable
, skippingskipCount
objects first, into the rangestart
, inclusive, toend
, exclusive, of the list. [...]inherited -
shuffle(
[Random random ]) → void -
Shuffles the elements of this list randomly.
inherited
-
singleWhere(
bool test(dynamic element), { dynamic orElse() }) → dynamic -
Returns the single element that satisfies
test
. [...]inherited -
skip(
int count) → Iterable -
Returns an
Iterable
that provides all but the firstcount
elements. [...]inherited -
skipWhile(
bool test(dynamic element)) → Iterable -
Returns an
Iterable
that skips leading elements whiletest
is satisfied. [...]inherited -
sort(
[int compare(dynamic a dynamic b) ]) → void -
Sorts this list according to the order specified by the
compare
function. [...]inherited -
sublist(
int start, [ int end ]) → List -
Returns a new list containing the elements between
start
andend
. [...]inherited -
take(
int count) → Iterable -
Returns a lazy iterable of the
count
first elements of this iterable. [...]inherited -
takeWhile(
bool test(dynamic element)) → Iterable -
Returns a lazy iterable of the leading elements satisfying
test
. [...]inherited -
toList(
{bool growable: true }) → List -
Creates a
List
containing the elements of thisIterable
. [...]inherited -
toSet(
) → Set -
Creates a
Set
containing the same elements as this iterable. [...]inherited -
where(
bool test(dynamic element)) → Iterable -
Returns a new lazy
Iterable
with all elements that satisfy the predicatetest
. [...]inherited -
whereType<
T> () → Iterable< T> -
Returns a new lazy
Iterable
with all elements that have typeT
. [...]inherited
Operators
-
operator [](
int index) → dynamic -
Returns the object at the given
index
in the list or throws aRangeError
ifindex
is out of bounds.override -
operator []=(
int index, dynamic item) → void -
Sets the value at the given
index
in the list tovalue
or throws aRangeError
ifindex
is out of bounds.override -
operator +(
List other) → List -
Returns the concatenation of this list and
other
. [...]inherited -
operator ==(
dynamic other) → bool -
The equality operator. [...]
inherited
Static Methods
-
fromString(
String values, [ String separator, [ bool removeDuplicates = false ]) → AnyValueArray - Splits specified string into elements using a separator and assigns the elements to a newly created AnyValueArray. [...]
-
fromValue(
dynamic value) → AnyValueArray - Converts specified value into AnyValueArray. [...]
-
fromValues(
List values) → AnyValueArray - Creates a new AnyValueArray from a list of values [...]