Appearance
StructPointer<T extends Struct>
Extension on Pointer specialized for the type argument Struct.
Properties
ref extension read / write
T get refA Dart view of the struct referenced by this pointer.
Reading ref creates a reference accessing the fields of this struct backed by native memory at address. The address must be aligned according to the struct alignment rules of the platform.
Assigning to ref copies contents of the struct into the native memory starting at address.
This extension method must be invoked on a receiver of type Pointer<T> where T is a compile-time constant type.
Available on Pointer<T extends NativeType>, provided by the StructPointer<T extends Struct> extension
Implementation
dart
external T get ref;
external set ref(T value);Methods
deprecated elementAt() extension
DEPRECATED
Use operator + instead
Pointer arithmetic (takes element size into account)
Available on Pointer<T extends NativeType>, provided by the StructPointer<T extends Struct> extension
Implementation
dart
@Deprecated('Use operator + instead')
external Pointer<T> elementAt(int index);refWithFinalizer() extension
T refWithFinalizer(
Pointer<NativeFinalizerFunction<Void Function(Pointer<Void> token)>> finalizer, {
Pointer<Void>? token,
})A Dart view of the struct referenced by this pointer.
Creates a reference accessing the fields of this struct backed by native memory at address. The address must be aligned according to the struct alignment rules of the platform.
Attaches finalizer to the backing store of the struct. If provided, token will be passed to finalizer, otherwise the pointer (this) itself will be passed. The pointer (this) must not be used anymore if the struct is not guaranteed to be kept alive. Prefer doing any native calls with the pointer before calling refWithFinalizer.
This extension method must be invoked on a receiver of type Pointer<T> where T is a compile-time constant type.
Available on Pointer<T extends NativeType>, provided by the StructPointer<T extends Struct> extension
Implementation
dart
@Since('3.7')
external T refWithFinalizer(
Pointer<NativeFinalizerFunction> finalizer, {
Pointer<Void>? token,
});Operators
operator +() extension
A pointer to the offsetth T after this one.
Returns a pointer to the T whose address is offset times the size of T after the address of this pointer. That is (this + offset).address == this.address + offset * sizeOf<T>().
Also (this + offset).value is equivalent to this[offset], and similarly for setting.
Available on Pointer<T extends NativeType>, provided by the StructPointer<T extends Struct> extension
Implementation
dart
external Pointer<T> operator +(int offset);operator -() extension
A pointer to the offsetth T before this one.
Equivalent to this + (-offset).
Returns a pointer to the T whose address is offset times the size of T before the address of this pointer. That is, (this - offset).address == this.address - offset * sizeOf<T>().
Also, (this - offset).value is equivalent to this[-offset], and similarly for setting,
Available on Pointer<T extends NativeType>, provided by the StructPointer<T extends Struct> extension
Implementation
dart
external Pointer<T> operator -(int offset);operator extension
T operator [](int index)Creates a reference to access the fields of this struct backed by native memory at address + sizeOf<T>() * index.
The address must be aligned according to the struct alignment rules of the platform.
This extension method must be invoked on a receiver of type Pointer<T> where T is a compile-time constant type.
Available on Pointer<T extends NativeType>, provided by the StructPointer<T extends Struct> extension
Implementation
dart
external T operator [](int index);operator []=() extension
void operator []=(int index, T value)Copies the value struct into native memory, starting at address * sizeOf<T>() * index.
This extension method must be invoked on a receiver of type Pointer<T> where T is a compile-time constant type.
Available on Pointer<T extends NativeType>, provided by the StructPointer<T extends Struct> extension
Implementation
dart
external void operator []=(int index, T value);