DataArray class abstract interface

An interface for a data array with property values accessed by int keys (or indexes).

See samples below to create a copied data array, a view wrapping an instance of the standard Iterable, and decoding one from JSON.

final copied = DataArray.of(['foo', 'bar', 2, null]);

final list = ['foo', 'bar', 2, null];
final view = DataArray.view(list);

final json = DataArray.decodeJson('["foo", "bar", 2, null]');

As this class is defined with the class modifier interface, the class can only be implemented, but not extended. This class also provides factory methods constructing instances of the default implementation provided by DataArrayView.

Implemented types
Implementers

Constructors

DataArray.decodeJson(String source)
Creates a data array from source containing an encoded JSON Array.
factory
DataArray.empty()
Creates an empty data array.
factory
DataArray.of([Iterable<Object?> source = const <Object>[]])
Creates a data array with items copied from source.
factory
DataArray.view(Iterable<Object?> source)
Creates a data array view backed by source.
factory

Properties

arrays Iterable<DataArray>
Returns an iterable for childs that can be represented as DataArray.
no setterinherited
hashCode int
The hash code for this object.
no setterinherited
isEmpty bool
Returns true if the collection has no elements.
no setterinherited
isNotEmpty bool
Returns true if the collection has at least one element.
no setterinherited
length int
Returns the number of elements in this collection.
no setterinherited
objects Iterable<DataObject>
Returns an iterable for childs that can be represented as DataObject.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

array(int key) DataArray
Returns a child data array at key.
inherited
arraysToList<T extends Object>(T map(DataArray array), {int? limit}) List<T>
Returns a list of T mapped from child data arrays using map function.
inherited
encodeJson({Object encodeTime(DateTime time)?}) String
Encodes this element into a JSON string.
inherited
exists(int key) bool
Returns true if the key references an existing value, null or non-null.
inherited
existsNonNull(int key) bool
Returns true if a value at key exists and that value is non-null.
inherited
existsNull(int key) bool
Returns true if a value at key exists and that value is null.
inherited
getBigInt(int key, {BigInt? min, BigInt? max}) BigInt
Returns a value at key as BigInt.
inherited
getBool(int key) bool
Returns a value at key as bool.
inherited
getDouble(int key, {double? min, double? max}) double
Returns a value at key as double.
inherited
getId(int key) Identifier
Returns a value at key as Identifier.
inherited
getInt(int key, {int? min, int? max}) int
Returns a value at key as int.
inherited
getNum(int key, {num? min, num? max}) num
Returns a value at key as num.
inherited
getString(int key) String
Returns a value at key as String.
inherited
getTimeUTC(int key, {DateTime parse(Object?)?}) DateTime
Returns a value at key as DateTime in the UTC time zone.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
object(int key) DataObject
Returns a child data object at key.
inherited
objectsToList<T extends Object>(T map(DataObject object), {int? limit}) List<T>
Returns a list of T mapped from child data objects using map function.
inherited
toJson() → dynamic
Returns data as an encodable object compatible with json.encode().
inherited
toNullableValues<T extends Object>() Iterable<T?>
Returns all values as an iterable of T?.
toString() String
A string representation of this object.
inherited
toValues<T extends Object>() Iterable<T>
Returns all values as an iterable of T.
tryArray(int key) DataArray?
Returns a child data array at key or null if missing.
inherited
tryBigInt(int key, {BigInt? min, BigInt? max}) BigInt?
Returns a value at key as BigInt or null if missing.
inherited
tryBool(int key) bool?
Returns a value at key as bool or null if missing.
inherited
tryDouble(int key, {double? min, double? max}) double?
Returns a value at key as double or null if missing.
inherited
tryId(int key) Identifier?
Returns a value at key as Identifier or null if missing.
inherited
tryInt(int key, {int? min, int? max}) int?
Returns a value at key as int or null if missing.
inherited
tryNum(int key, {num? min, num? max}) num?
Returns a value at key as num or null if missing.
inherited
tryObject(int key) DataObject?
Returns a child data object at key or null if missing.
inherited
tryString(int key) String?
Returns a value at key as String or null if missing.
inherited
tryTimeUTC(int key, {DateTime parse(Object?)?}) DateTime?
Returns a value at key as DateTime in the UTC time zone, or null.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited
operator [](int key) Object?
Returns a value at key, the result can be of any object or null.
inherited

Static Methods

from<T extends Object>(Iterable<T> source, Object convert(T)) DataArray
Creates a data array with items mapped from source list of T.