StructData<K extends Field<V>, V> extension type

StructData — zero-cost keyed view over an existing object.

Handle key implementations, mapping to data Provide common data interface.

Provides operator[] access via Field keys without allocation. The wrapped object's memory layout is unchanged; all dispatch goes through Field.getIn/Field.setIn.

Contraint provided by type markers K extends Field ensures that only valid keys can be used

final view = Structure<PersonField, Object>(personInstance);
print(view[PersonField.name]); // delegates to PersonField.name.getIn(person)

K binds type safety V applies to some heterogeneous structs, but can be Object for generality

on
Implemented types
Implementers

Constructors

StructData(Object _data)
const

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

field(K key) StructField<K, V>
fieldAs<R>(Field<R> key) StructField<Field<R>, R>
fieldOrNull(K key) → V?
fieldsAs(StructForm<K, V> type) Iterable<StructField<K, V>>
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toMapWith(StructForm<K, V> type) Map<K, V>
toString() String
A string representation of this object.
inherited
trySetField(K key, V value) bool
valuesAs(StructForm<K, V> type) Iterable<V>

Operators

operator ==(Object other) bool
The equality operator.
inherited
operator [](K key) → V
operator []=(K key, V value) → void