StructPointer<T extends Struct>#
Extension on Pointer specialized for the type argument Struct.
Properties#
ref extension read / write#
A 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
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
@Deprecated('Use operator + instead')
external Pointer<T> elementAt(int index);
refWithFinalizer() extension#
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
@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
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
external Pointer<T> operator -(int offset);
operator []() extension#
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
external T operator [](int index);
operator []=() extension#
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
external void operator []=(int index, T value);