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
- Implemented types
- Available Extensions
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
- first ↔ dynamic
-
The first element.
getter/setter pairinherited
- hashCode → int
-
The hash code for this object.
no setterinherited
- isEmpty → bool
-
Whether this collection has no elements.
no setterinherited
- isNotEmpty → bool
-
Whether this collection has at least one element.
no setterinherited
- iterator → Iterator
-
A new
Iterator
that allows iterating the elements of thisIterable
.no setterinherited - last ↔ dynamic
-
The last element.
getter/setter pairinherited
- length ↔ int
-
The number of objects in this list.
getter/setter pairoverride
- reversed → Iterable
-
An Iterable of the objects in this list in reverse order.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- single → dynamic
-
Checks that this iterable has only one element, and returns that element.
no setterinherited
Methods
-
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 -
append(
dynamic elements) → void - Appends new elements to this array.
-
asMap(
) → Map< int, dynamic> -
An unmodifiable Map view of this list.
inherited
-
cast<
R> () → List< R> -
Returns a view of this list as a list of
R
instances.inherited -
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.
-
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 -
Overwrites a range of elements with
fillValue
.inherited -
firstWhere(
bool test(dynamic element), {dynamic orElse()?}) → dynamic -
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 -
Creates the lazy concatenation of this iterable and
other
.inherited -
forEach(
void action(dynamic element)) → void -
Invokes
action
on each element of this iterable in iteration order.inherited -
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.
-
getRange(
int start, int end) → Iterable -
Creates an Iterable that iterates over a range of elements.
inherited
-
getValue(
) → List - Gets an array with values.
-
indexOf(
Object? element, [int start = 0]) → int -
The first index of
element
in this list.inherited -
indexWhere(
bool test(dynamic element), [int start = 0]) → int -
The first index in the list that satisfies the provided
test
.inherited -
innerValue(
) → dynamic - Returned inner values in Map object
-
insert(
int index, dynamic element) → void -
Inserts
element
at positionindex
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 -
The last index of
element
in this list.inherited -
lastIndexWhere(
bool test(dynamic element), [int? start]) → int -
The last index in the list that satisfies the provided
test
.inherited -
lastWhere(
bool test(dynamic element), {dynamic orElse()?}) → dynamic -
The last element that satisfies the given predicate
test
.inherited -
map<
T> (T f(dynamic element)) → Iterable< T> -
The current elements of this iterable modified by
toElement
.inherited -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
put(
int index, dynamic value) → void - Puts a new value into array element specified by its index.
-
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 -
Removes and returns the last object in this list.
inherited
-
removeRange(
int start, int end) → void -
Removes a range of elements from the list.
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 -
Replaces a range of elements with the elements of
replacements
.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 elements with the objects of
iterable
.inherited -
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.
-
setRange(
int start, int end, Iterable iterable, [int skipCount = 0]) → void -
Writes some elements of
iterable
into a range of this list.inherited -
shuffle(
[Random? random]) → void -
Shuffles the elements of this list randomly.
inherited
-
singleWhere(
bool test(dynamic element), {dynamic orElse()?}) → dynamic -
The single element that satisfies
test
.inherited -
skip(
int count) → Iterable -
Creates an Iterable that provides all but the first
count
elements.inherited -
skipWhile(
bool test(dynamic element)) → Iterable -
Creates 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 -
Creates a lazy iterable of the
count
first elements of this iterable.inherited -
takeWhile(
bool test(dynamic element)) → Iterable -
Creates a lazy iterable of the leading elements satisfying
test
.inherited -
toJson(
) → Map< String, dynamic> - Returned JSON Map object from values of this object
-
toList(
{bool growable = true}) → List -
Creates a List containing the elements of this Iterable.
inherited
-
toSet(
) → Set -
Creates a Set containing the same elements as this iterable.
inherited
-
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
-
where(
bool test(dynamic element)) → Iterable -
Creates a new lazy Iterable with all elements that satisfy the
predicate
test
.inherited -
whereType<
T> () → Iterable< T> -
Creates a new lazy Iterable with all elements that have type
T
.inherited
Operators
-
operator +(
List other) → List -
Returns the concatenation of this list and
other
.inherited -
operator ==(
Object other) → bool -
The equality operator.
inherited
-
operator [](
int index) → dynamic -
The object at the given
index
in the list.override -
operator []=(
int index, dynamic item) → void -
Sets the value at the given
index
in the list tovalue
.override
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