Appearance
UnionAddress<T extends Union>
extension UnionAddress<T extends Union> on TAnnotations: @Since.new('3.5')
Properties
address extension no setter
Pointer<T> get addressThe memory address of the underlying data.
An expression of the form expression.address denoting this address can only occurr as an entire argument expression in the invocation of a leaf Native external function.
Example:
dart
@Native<Void Function(Pointer<MyUnion>)>(isLeaf: true)
external void myFunction(Pointer<MyUnion> pointer);
final class MyUnion extends Union {
@Int8()
external int x;
}
void main() {
final myUnion = Union.create<MyUnion>();
myFunction(myUnion.address);
}The expression before .address is evaluated like the left-hand-side of an assignment, to something that gives access to the storage behind the expression, which can be used both for reading and writing. The .address then gives a native pointer to that storage.
The .address is evaluated just before calling into native code when invoking a leaf Native external function. This ensures the Dart garbage collector will not move the object that the address points in to.
Available on T extends Union, provided by the UnionAddress<T extends Union> extension
Implementation
dart
external Pointer<T> get address;