Pointer<T extends NativeType> final#
Represents a pointer into the native C memory. Cannot be extended.
Implemented types
Available Extensions
- AbiSpecificIntegerPointer<T extends AbiSpecificInteger>
- BoolPointer
- DoublePointer
- FloatPointer
- Int8Pointer
- Int16Pointer
- Int32Pointer
- Int64Pointer
- NativeFunctionPointer<NF extends Function>
- PointerPointer<T extends NativeType>
- StructPointer<T extends Struct>
- Uint8Pointer
- Uint16Pointer
- Uint32Pointer
- Uint64Pointer
- UnionPointer<T extends Union>
Constructors#
Pointer.fromAddress() factory#
Construction from raw integer.
Implementation
external factory Pointer.fromAddress(int ptr);
Properties#
address no setter#
Access to the raw pointer value. On 32-bit systems, the upper 32-bits of the result are 0.
Implementation
external int get address;
hashCode no setter override#
The hash code for a Pointer only depends on its address.
Implementation
int get hashCode {
return address.hashCode;
}
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);
ref extension read / write#
A Dart view of the union referenced by this pointer.
Reading ref creates a reference accessing the fields of this union backed by native memory at address. The address must be aligned according to the union alignment rules of the platform.
Assigning to ref copies contents of the union 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 UnionPointer<T extends Union> extension
Implementation
external T get ref;
external set ref(T value);
runtimeType no setter inherited#
A representation of the runtime type of the object.
Inherited from Object.
Implementation
external Type get runtimeType;
value extension read / write#
The integer at address.
Available on Pointer<T extends NativeType>, provided by the AbiSpecificIntegerPointer<T extends AbiSpecificInteger> extension
Implementation
external int get value;
external void set value(int value);
value extension read / write#
The bool at address.
Available on Pointer<T extends NativeType>, provided by the BoolPointer extension
Implementation
external bool get value;
external void set value(bool value);
value extension read / write#
The double at address.
The address must be 8-byte aligned.
Available on Pointer<T extends NativeType>, provided by the DoublePointer extension
Implementation
external double get value;
external void set value(double value);
value extension read / write#
The float at address.
A Dart double loses precision before being stored, and the float value is converted to a double when it is loaded.
The address must be 4-byte aligned.
Available on Pointer<T extends NativeType>, provided by the FloatPointer extension
Implementation
external double get value;
external void set value(double value);
value extension read / write#
The 8-bit two's complement integer at address.
A Dart integer is truncated to 8 bits (as if by .toSigned(8)) before
being stored, and the 8-bit value is sign-extended when it is loaded.
Available on Pointer<T extends NativeType>, provided by the Int8Pointer extension
Implementation
external int get value;
external void set value(int value);
value extension read / write#
The 16-bit two's complement integer at address.
A Dart integer is truncated to 16 bits (as if by .toSigned(16)) before
being stored, and the 16-bit value is sign-extended when it is loaded.
The address must be 2-byte aligned.
Available on Pointer<T extends NativeType>, provided by the Int16Pointer extension
Implementation
external int get value;
external void set value(int value);
value extension read / write#
The 32-bit two's complement integer at address.
A Dart integer is truncated to 32 bits (as if by .toSigned(32)) before
being stored, and the 32-bit value is sign-extended when it is loaded.
The address must be 4-byte aligned.
Available on Pointer<T extends NativeType>, provided by the Int32Pointer extension
Implementation
external int get value;
external void set value(int value);
value extension read / write#
The 64-bit two's complement integer at address.
The address must be 8-byte aligned.
Available on Pointer<T extends NativeType>, provided by the Int64Pointer extension
Implementation
external int get value;
external void set value(int value);
value extension read / write#
The pointer at address.
A Pointer is unboxed before being stored (as if by
.address), and the
pointer is boxed (as if by Pointer.fromAddress) when loaded.
On 32-bit platforms the address must be 4-byte aligned, and on 64-bit platforms the address must be 8-byte aligned.
Available on Pointer<T extends NativeType>, provided by the PointerPointer<T extends NativeType> extension
Implementation
external Pointer<T> get value;
external void set value(Pointer<T> value);
value extension read / write#
The 8-bit unsigned integer at address.
A Dart integer is truncated to 8 bits (as if by .toUnsigned(8)) before
being stored, and the 8-bit value is zero-extended when it is loaded.
Available on Pointer<T extends NativeType>, provided by the Uint8Pointer extension
Implementation
external int get value;
external void set value(int value);
value extension read / write#
The 16-bit unsigned integer at address.
A Dart integer is truncated to 16 bits (as if by .toUnsigned(16)) before
being stored, and the 16-bit value is zero-extended when it is loaded.
The address must be 2-byte aligned.
Available on Pointer<T extends NativeType>, provided by the Uint16Pointer extension
Implementation
external int get value;
external void set value(int value);
value extension read / write#
The 32-bit unsigned integer at address.
A Dart integer is truncated to 32 bits (as if by .toUnsigned(32)) before
being stored, and the 32-bit value is zero-extended when it is loaded.
The address must be 4-byte aligned.
Available on Pointer<T extends NativeType>, provided by the Uint32Pointer extension
Implementation
external int get value;
external void set value(int value);
value extension read / write#
The 64-bit unsigned integer at address.
The address must be 8-byte aligned.
Available on Pointer<T extends NativeType>, provided by the Uint64Pointer extension
Implementation
external int get value;
external void set value(int value);
Methods#
asFunction() extension#
Convert to Dart function, automatically marshalling the arguments and return value.
isLeaf specifies whether the function is a leaf function. Leaf functions
are small, short-running, non-blocking functions which are not allowed to
call back into Dart or use any Dart VM APIs. Leaf functions are invoked
bypassing some of the heavier parts of the standard Dart-to-Native calling
sequence which reduces the invocation overhead, making leaf calls faster
than non-leaf calls. However, this implies that a thread executing a leaf
function can't cooperate with the Dart runtime. A long running or blocking
leaf function will delay any operation which requires synchronization
between all threads associated with an isolate group until after the leaf
function returns. For example, if one isolate in a group is trying to
perform a GC and a second isolate is blocked in a leaf call, then the
first isolate will have to pause and wait until this leaf call returns.
Available on Pointer<T extends NativeType>, provided by the NativeFunctionPointer<NF extends Function> extension
Implementation
external DF asFunction<@DartRepresentationOf('NF') DF extends Function>({
bool isLeaf = false,
});
asTypedList() extension#
Creates a typed list view backed by memory in the address space.
The returned view will allow access to the memory range from address
to address + sizeOf<Double>() * length.
The user has to ensure the memory range is accessible while using the returned list.
If provided, finalizer will be run on the pointer once the typed list
is GCed. If provided, token will be passed to finalizer, otherwise
the this pointer itself will be passed.
The address must be 8-byte aligned.
Available on Pointer<T extends NativeType>, provided by the DoublePointer extension
Implementation
external Float64List asTypedList(
int length, {
@Since('3.1') Pointer<NativeFinalizerFunction>? finalizer,
@Since('3.1') Pointer<Void>? token,
});
asTypedList() extension#
Creates a typed list view backed by memory in the address space.
The returned view will allow access to the memory range from address
to address + sizeOf<Float>() * length.
The user has to ensure the memory range is accessible while using the returned list.
If provided, finalizer will be run on the pointer once the typed list
is GCed. If provided, token will be passed to finalizer, otherwise
the this pointer itself will be passed.
The address must be 4-byte aligned.
Available on Pointer<T extends NativeType>, provided by the FloatPointer extension
Implementation
external Float32List asTypedList(
int length, {
@Since('3.1') Pointer<NativeFinalizerFunction>? finalizer,
@Since('3.1') Pointer<Void>? token,
});
asTypedList() extension#
Creates a typed list view backed by memory in the address space.
The returned view will allow access to the memory range from address
to address + sizeOf<Int8>() * length.
The user has to ensure the memory range is accessible while using the returned list.
If provided, finalizer will be run on the pointer once the typed list
is GCed. If provided, token will be passed to finalizer, otherwise
the this pointer itself will be passed.
Available on Pointer<T extends NativeType>, provided by the Int8Pointer extension
Implementation
external Int8List asTypedList(
int length, {
@Since('3.1') Pointer<NativeFinalizerFunction>? finalizer,
@Since('3.1') Pointer<Void>? token,
});
asTypedList() extension#
Creates a typed list view backed by memory in the address space.
The returned view will allow access to the memory range from address
to address + sizeOf<Int16>() * length.
The user has to ensure the memory range is accessible while using the returned list.
If provided, finalizer will be run on the pointer once the typed list
is GCed. If provided, token will be passed to finalizer, otherwise
the this pointer itself will be passed.
The address must be 2-byte aligned.
Available on Pointer<T extends NativeType>, provided by the Int16Pointer extension
Implementation
external Int16List asTypedList(
int length, {
@Since('3.1') Pointer<NativeFinalizerFunction>? finalizer,
@Since('3.1') Pointer<Void>? token,
});
asTypedList() extension#
Creates a typed list view backed by memory in the address space.
The returned view will allow access to the memory range from address
to address + sizeOf<Int32>() * length.
The user has to ensure the memory range is accessible while using the returned list.
If provided, finalizer will be run on the pointer once the typed list
is GCed. If provided, token will be passed to finalizer, otherwise
the this pointer itself will be passed.
The address must be 4-byte aligned.
Available on Pointer<T extends NativeType>, provided by the Int32Pointer extension
Implementation
external Int32List asTypedList(
int length, {
@Since('3.1') Pointer<NativeFinalizerFunction>? finalizer,
@Since('3.1') Pointer<Void>? token,
});
asTypedList() extension#
Creates a typed list view backed by memory in the address space.
The returned view will allow access to the memory range from address
to address + sizeOf<Int64>() * length.
The user has to ensure the memory range is accessible while using the returned list.
If provided, finalizer will be run on the pointer once the typed list
is GCed. If provided, token will be passed to finalizer, otherwise
the this pointer itself will be passed.
The address must be 8-byte aligned.
Available on Pointer<T extends NativeType>, provided by the Int64Pointer extension
Implementation
external Int64List asTypedList(
int length, {
@Since('3.1') Pointer<NativeFinalizerFunction>? finalizer,
@Since('3.1') Pointer<Void>? token,
});
asTypedList() extension#
Creates a typed list view backed by memory in the address space.
The returned view will allow access to the memory range from address
to address + sizeOf<Uint8>() * length.
The user has to ensure the memory range is accessible while using the returned list.
If provided, finalizer will be run on the pointer once the typed list
is GCed. If provided, token will be passed to finalizer, otherwise
the this pointer itself will be passed.
Available on Pointer<T extends NativeType>, provided by the Uint8Pointer extension
Implementation
external Uint8List asTypedList(
int length, {
@Since('3.1') Pointer<NativeFinalizerFunction>? finalizer,
@Since('3.1') Pointer<Void>? token,
});
asTypedList() extension#
Creates a typed list view backed by memory in the address space.
The returned view will allow access to the memory range from address
to address + sizeOf<Uint16>() * length.
The user has to ensure the memory range is accessible while using the returned list.
If provided, finalizer will be run on the pointer once the typed list
is GCed. If provided, token will be passed to finalizer, otherwise
the this pointer itself will be passed.
The address must be 2-byte aligned.
Available on Pointer<T extends NativeType>, provided by the Uint16Pointer extension
Implementation
external Uint16List asTypedList(
int length, {
@Since('3.1') Pointer<NativeFinalizerFunction>? finalizer,
@Since('3.1') Pointer<Void>? token,
});
asTypedList() extension#
Creates a typed list view backed by memory in the address space.
The returned view will allow access to the memory range from address
to address + sizeOf<Uint32>() * length.
The user has to ensure the memory range is accessible while using the returned list.
If provided, finalizer will be run on the pointer once the typed list
is GCed. If provided, token will be passed to finalizer, otherwise
the this pointer itself will be passed.
The address must be 4-byte aligned.
Available on Pointer<T extends NativeType>, provided by the Uint32Pointer extension
Implementation
external Uint32List asTypedList(
int length, {
@Since('3.1') Pointer<NativeFinalizerFunction>? finalizer,
@Since('3.1') Pointer<Void>? token,
});
asTypedList() extension#
Creates a typed list view backed by memory in the address space.
The returned view will allow access to the memory range from address
to address + sizeOf<Uint64>() * length.
The user has to ensure the memory range is accessible while using the returned list.
If provided, finalizer will be run on the pointer once the typed list
is GCed. If provided, token will be passed to finalizer, otherwise
the this pointer itself will be passed.
The address must be 8-byte aligned.
Available on Pointer<T extends NativeType>, provided by the Uint64Pointer extension
Implementation
external Uint64List asTypedList(
int length, {
@Since('3.1') Pointer<NativeFinalizerFunction>? finalizer,
@Since('3.1') Pointer<Void>? token,
});
cast()#
Reinterprets the address of this pointer as the address of a U.
This function is completely unchecked, no attempts are made to validate
that the bytes at the address are actually a valid native value
of type U.
Implementation
external Pointer<U> cast<U extends NativeType>();
deprecated elementAt() extension#
DEPRECATED
Use operator + instead
Pointer arithmetic (takes element size into account).
Available on Pointer<T extends NativeType>, provided by the AbiSpecificIntegerPointer<T extends AbiSpecificInteger> extension
Implementation
@Deprecated('Use operator + instead')
external Pointer<T> elementAt(int index);
deprecated elementAt() extension#
DEPRECATED
Use operator + instead
Pointer arithmetic (takes element size into account).
Available on Pointer<T extends NativeType>, provided by the BoolPointer extension
Implementation
@Deprecated('Use operator + instead')
Pointer<Bool> elementAt(int index) =>
Pointer.fromAddress(address + sizeOf<Bool>() * index);
deprecated elementAt() extension#
DEPRECATED
Use operator + instead
Pointer arithmetic (takes element size into account).
Available on Pointer<T extends NativeType>, provided by the DoublePointer extension
Implementation
@Deprecated('Use operator + instead')
Pointer<Double> elementAt(int index) =>
Pointer.fromAddress(address + sizeOf<Double>() * index);
deprecated elementAt() extension#
DEPRECATED
Use operator + instead
Pointer arithmetic (takes element size into account).
Available on Pointer<T extends NativeType>, provided by the FloatPointer extension
Implementation
@Deprecated('Use operator + instead')
Pointer<Float> elementAt(int index) =>
Pointer.fromAddress(address + sizeOf<Float>() * index);
deprecated elementAt() extension#
DEPRECATED
Use operator + instead
Pointer arithmetic (takes element size into account).
Available on Pointer<T extends NativeType>, provided by the Int8Pointer extension
Implementation
@Deprecated('Use operator + instead')
Pointer<Int8> elementAt(int index) =>
Pointer.fromAddress(address + sizeOf<Int8>() * index);
deprecated elementAt() extension#
DEPRECATED
Use operator + instead
Pointer arithmetic (takes element size into account).
Available on Pointer<T extends NativeType>, provided by the Int16Pointer extension
Implementation
@Deprecated('Use operator + instead')
Pointer<Int16> elementAt(int index) =>
Pointer.fromAddress(address + sizeOf<Int16>() * index);
deprecated elementAt() extension#
DEPRECATED
Use operator + instead
Pointer arithmetic (takes element size into account).
Available on Pointer<T extends NativeType>, provided by the Int32Pointer extension
Implementation
@Deprecated('Use operator + instead')
Pointer<Int32> elementAt(int index) =>
Pointer.fromAddress(address + sizeOf<Int32>() * index);
deprecated elementAt() extension#
DEPRECATED
Use operator + instead
Pointer arithmetic (takes element size into account).
Available on Pointer<T extends NativeType>, provided by the Int64Pointer extension
Implementation
@Deprecated('Use operator + instead')
Pointer<Int64> elementAt(int index) =>
Pointer.fromAddress(address + sizeOf<Int64>() * index);
deprecated elementAt() extension#
DEPRECATED
Use operator + instead
Pointer arithmetic (takes element size into account).
Available on Pointer<T extends NativeType>, provided by the PointerPointer<T extends NativeType> extension
Implementation
@Deprecated('Use operator + instead')
external Pointer<Pointer<T>> elementAt(int index);
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);
deprecated elementAt() extension#
DEPRECATED
Use operator + instead
Pointer arithmetic (takes element size into account).
Available on Pointer<T extends NativeType>, provided by the Uint8Pointer extension
Implementation
@Deprecated('Use operator + instead')
Pointer<Uint8> elementAt(int index) =>
Pointer.fromAddress(address + sizeOf<Uint8>() * index);
deprecated elementAt() extension#
DEPRECATED
Use operator + instead
Pointer arithmetic (takes element size into account).
Available on Pointer<T extends NativeType>, provided by the Uint16Pointer extension
Implementation
@Deprecated('Use operator + instead')
Pointer<Uint16> elementAt(int index) =>
Pointer.fromAddress(address + sizeOf<Uint16>() * index);
deprecated elementAt() extension#
DEPRECATED
Use operator + instead
Pointer arithmetic (takes element size into account).
Available on Pointer<T extends NativeType>, provided by the Uint32Pointer extension
Implementation
@Deprecated('Use operator + instead')
Pointer<Uint32> elementAt(int index) =>
Pointer.fromAddress(address + sizeOf<Uint32>() * index);
deprecated elementAt() extension#
DEPRECATED
Use operator + instead
Pointer arithmetic (takes element size into account).
Available on Pointer<T extends NativeType>, provided by the Uint64Pointer extension
Implementation
@Deprecated('Use operator + instead')
Pointer<Uint64> elementAt(int index) =>
Pointer.fromAddress(address + sizeOf<Uint64>() * index);
deprecated elementAt() extension#
DEPRECATED
Use operator + instead
Pointer arithmetic (takes element size into account).
Available on Pointer<T extends NativeType>, provided by the UnionPointer<T extends Union> extension
Implementation
@Deprecated('Use operator + instead')
external Pointer<T> elementAt(int index);
noSuchMethod() inherited#
Invoked when a nonexistent method or property is accessed.
A dynamic member invocation can attempt to call a member which doesn't exist on the receiving object. Example:
dynamic object = 1;
object.add(42); // Statically allowed, run-time error
This invalid code will invoke the noSuchMethod method
of the integer 1 with an Invocation
representing the
.add(42) call and arguments (which then throws).
Classes can override noSuchMethod to provide custom behavior for such invalid dynamic invocations.
A class with a non-default noSuchMethod invocation can also omit implementations for members of its interface. Example:
class MockList<T> implements List<T> {
noSuchMethod(Invocation invocation) {
log(invocation);
super.noSuchMethod(invocation); // Will throw.
}
}
void main() {
MockList().add(42);
}
This code has no compile-time warnings or errors even though
the MockList class has no concrete implementation of
any of the List interface methods.
Calls to List methods are forwarded to noSuchMethod,
so this code will log an invocation similar to
Invocation.method(#add, [42])
and then throw.
If a value is returned from noSuchMethod,
it becomes the result of the original invocation.
If the value is not of a type that can be returned by the original
invocation, a type error occurs at the invocation.
The default behavior is to throw a NoSuchMethodError.
Inherited from Object.
Implementation
@pragma("vm:entry-point")
@pragma("wasm:entry-point")
external dynamic noSuchMethod(Invocation invocation);
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,
});
refWithFinalizer() extension#
A Dart view of the union referenced by this pointer.
Creates a reference accessing the fields of this union backed by native memory at address. The address must be aligned according to the union alignment rules of the platform.
Attaches finalizer to the backing store of the union. 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 union 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 UnionPointer<T extends Union> extension
Implementation
@Since('3.7')
external T refWithFinalizer(
Pointer<NativeFinalizerFunction> finalizer, {
Pointer<Void>? token,
});
toString() inherited#
A string representation of this object.
Some classes have a default textual representation,
often paired with a static parse function (like int.parse).
These classes will provide the textual representation as
their string representation.
Other classes have no meaningful textual representation
that a program will care about.
Such classes will typically override toString to provide
useful information when inspecting the object,
mainly for debugging or logging.
Inherited from Object.
Implementation
external String toString();
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 UnionPointer<T extends Union> extension
Implementation
external Pointer<T> operator +(int offset);
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 AbiSpecificIntegerPointer<T extends AbiSpecificInteger> extension
Implementation
external Pointer<T> operator +(int offset);
operator +() extension#
A pointer to the offsetth Bool
after this one.
Returns a pointer to the Bool
whose address is
offset times the size of Bool
after the address of this pointer.
That is (this + offset).address == this.address + offset * sizeOf<Bool>().
Also (this + offset).value is equivalent to this[offset],
and similarly for setting.
Available on Pointer<T extends NativeType>, provided by the BoolPointer extension
Implementation
@Since('3.3')
@pragma("vm:prefer-inline")
Pointer<Bool> operator +(int offset) =>
Pointer.fromAddress(address + sizeOf<Bool>() * offset);
operator +() extension#
A pointer to the offsetth Double
after this one.
Returns a pointer to the Double
whose address is
offset times the size of Double
after the address of this pointer.
That is (this + offset).address == this.address + offset * sizeOf<Double>().
Also (this + offset).value is equivalent to this[offset],
and similarly for setting.
Available on Pointer<T extends NativeType>, provided by the DoublePointer extension
Implementation
@Since('3.3')
@pragma("vm:prefer-inline")
Pointer<Double> operator +(int offset) =>
Pointer.fromAddress(address + sizeOf<Double>() * offset);
operator +() extension#
A pointer to the offsetth Float
after this one.
Returns a pointer to the Float
whose address is
offset times the size of Float
after the address of this pointer.
That is (this + offset).address == this.address + offset * sizeOf<Float>().
Also (this + offset).value is equivalent to this[offset],
and similarly for setting.
Available on Pointer<T extends NativeType>, provided by the FloatPointer extension
Implementation
@Since('3.3')
@pragma("vm:prefer-inline")
Pointer<Float> operator +(int offset) =>
Pointer.fromAddress(address + sizeOf<Float>() * offset);
operator +() extension#
A pointer to the offsetth Int8
after this one.
Returns a pointer to the Int8
whose address is
offset times the size of Int8
after the address of this pointer.
That is (this + offset).address == this.address + offset * sizeOf<Int8>().
Also (this + offset).value is equivalent to this[offset],
and similarly for setting.
Available on Pointer<T extends NativeType>, provided by the Int8Pointer extension
Implementation
@Since('3.3')
@pragma("vm:prefer-inline")
Pointer<Int8> operator +(int offset) =>
Pointer.fromAddress(address + sizeOf<Int8>() * offset);
operator +() extension#
A pointer to the offsetth Int16
after this one.
Returns a pointer to the Int16
whose address is
offset times the size of Int16
after the address of this pointer.
That is (this + offset).address == this.address + offset * sizeOf<Int16>().
Also (this + offset).value is equivalent to this[offset],
and similarly for setting.
Available on Pointer<T extends NativeType>, provided by the Int16Pointer extension
Implementation
@Since('3.3')
@pragma("vm:prefer-inline")
Pointer<Int16> operator +(int offset) =>
Pointer.fromAddress(address + sizeOf<Int16>() * offset);
operator +() extension#
A pointer to the offsetth Int32
after this one.
Returns a pointer to the Int32
whose address is
offset times the size of Int32
after the address of this pointer.
That is (this + offset).address == this.address + offset * sizeOf<Int32>().
Also (this + offset).value is equivalent to this[offset],
and similarly for setting.
Available on Pointer<T extends NativeType>, provided by the Int32Pointer extension
Implementation
@Since('3.3')
@pragma("vm:prefer-inline")
Pointer<Int32> operator +(int offset) =>
Pointer.fromAddress(address + sizeOf<Int32>() * offset);
operator +() extension#
A pointer to the offsetth Int64
after this one.
Returns a pointer to the Int64
whose address is
offset times the size of Int64
after the address of this pointer.
That is (this + offset).address == this.address + offset * sizeOf<Int64>().
Also (this + offset).value is equivalent to this[offset],
and similarly for setting.
Available on Pointer<T extends NativeType>, provided by the Int64Pointer extension
Implementation
@Since('3.3')
@pragma("vm:prefer-inline")
Pointer<Int64> operator +(int offset) =>
Pointer.fromAddress(address + sizeOf<Int64>() * offset);
operator +() extension#
A pointer to the offsetth Pointer<T>
after this one.
Returns a pointer to the Pointer<T>
whose address is
offset times the size of Pointer<T> after the address of this pointer.
That is (this + offset).address == this.address + offset * sizeOf<Pointer<T>>().
Also (this + offset).value is equivalent to this[offset],
and similarly for setting.
Available on Pointer<T extends NativeType>, provided by the PointerPointer<T extends NativeType> extension
Implementation
external Pointer<Pointer<T>> operator +(int offset);
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 Uint8
after this one.
Returns a pointer to the Uint8
whose address is
offset times the size of Uint8
after the address of this pointer.
That is (this + offset).address == this.address + offset * sizeOf<Uint8>().
Also (this + offset).value is equivalent to this[offset],
and similarly for setting.
Available on Pointer<T extends NativeType>, provided by the Uint8Pointer extension
Implementation
@Since('3.3')
@pragma("vm:prefer-inline")
Pointer<Uint8> operator +(int offset) =>
Pointer.fromAddress(address + sizeOf<Uint8>() * offset);
operator +() extension#
A pointer to the offsetth Uint16
after this one.
Returns a pointer to the Uint16
whose address is
offset times the size of Uint16
after the address of this pointer.
That is (this + offset).address == this.address + offset * sizeOf<Uint16>().
Also (this + offset).value is equivalent to this[offset],
and similarly for setting.
Available on Pointer<T extends NativeType>, provided by the Uint16Pointer extension
Implementation
@Since('3.3')
@pragma("vm:prefer-inline")
Pointer<Uint16> operator +(int offset) =>
Pointer.fromAddress(address + sizeOf<Uint16>() * offset);
operator +() extension#
A pointer to the offsetth Uint32
after this one.
Returns a pointer to the Uint32
whose address is
offset times the size of Uint32
after the address of this pointer.
That is (this + offset).address == this.address + offset * sizeOf<Uint32>().
Also (this + offset).value is equivalent to this[offset],
and similarly for setting.
Available on Pointer<T extends NativeType>, provided by the Uint32Pointer extension
Implementation
@Since('3.3')
@pragma("vm:prefer-inline")
Pointer<Uint32> operator +(int offset) =>
Pointer.fromAddress(address + sizeOf<Uint32>() * offset);
operator +() extension#
A pointer to the offsetth Uint64
after this one.
Returns a pointer to the Uint64
whose address is
offset times the size of Uint64
after the address of this pointer.
That is (this + offset).address == this.address + offset * sizeOf<Uint64>().
Also (this + offset).value is equivalent to this[offset],
and similarly for setting.
Available on Pointer<T extends NativeType>, provided by the Uint64Pointer extension
Implementation
@Since('3.3')
@pragma("vm:prefer-inline")
Pointer<Uint64> operator +(int offset) =>
Pointer.fromAddress(address + sizeOf<Uint64>() * 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#
A pointer to the offsetth Uint32
before this one.
Equivalent to this + (-offset).
Returns a pointer to the Uint32
whose address is
offset times the size of Uint32
before the address of this pointer.
That is, (this - offset).address == this.address - offset * sizeOf<Uint32>().
Also, (this - offset).value is equivalent to this[-offset],
and similarly for setting,
Available on Pointer<T extends NativeType>, provided by the Uint32Pointer extension
Implementation
@Since('3.3')
@pragma("vm:prefer-inline")
Pointer<Uint32> operator -(int offset) =>
Pointer.fromAddress(address - sizeOf<Uint32>() * offset);
operator -() extension#
A pointer to the offsetth Uint8
before this one.
Equivalent to this + (-offset).
Returns a pointer to the Uint8
whose address is
offset times the size of Uint8
before the address of this pointer.
That is, (this - offset).address == this.address - offset * sizeOf<Uint8>().
Also, (this - offset).value is equivalent to this[-offset],
and similarly for setting,
Available on Pointer<T extends NativeType>, provided by the Uint8Pointer extension
Implementation
@Since('3.3')
@pragma("vm:prefer-inline")
Pointer<Uint8> operator -(int offset) =>
Pointer.fromAddress(address - sizeOf<Uint8>() * offset);
operator -() extension#
A pointer to the offsetth Int16
before this one.
Equivalent to this + (-offset).
Returns a pointer to the Int16
whose address is
offset times the size of Int16
before the address of this pointer.
That is, (this - offset).address == this.address - offset * sizeOf<Int16>().
Also, (this - offset).value is equivalent to this[-offset],
and similarly for setting,
Available on Pointer<T extends NativeType>, provided by the Int16Pointer extension
Implementation
@Since('3.3')
@pragma("vm:prefer-inline")
Pointer<Int16> operator -(int offset) =>
Pointer.fromAddress(address - sizeOf<Int16>() * offset);
operator -() extension#
A pointer to the offsetth Int32
before this one.
Equivalent to this + (-offset).
Returns a pointer to the Int32
whose address is
offset times the size of Int32
before the address of this pointer.
That is, (this - offset).address == this.address - offset * sizeOf<Int32>().
Also, (this - offset).value is equivalent to this[-offset],
and similarly for setting,
Available on Pointer<T extends NativeType>, provided by the Int32Pointer extension
Implementation
@Since('3.3')
@pragma("vm:prefer-inline")
Pointer<Int32> operator -(int offset) =>
Pointer.fromAddress(address - sizeOf<Int32>() * offset);
operator -() extension#
A pointer to the offsetth Float
before this one.
Equivalent to this + (-offset).
Returns a pointer to the Float
whose address is
offset times the size of Float
before the address of this pointer.
That is, (this - offset).address == this.address - offset * sizeOf<Float>().
Also, (this - offset).value is equivalent to this[-offset],
and similarly for setting,
Available on Pointer<T extends NativeType>, provided by the FloatPointer extension
Implementation
@Since('3.3')
@pragma("vm:prefer-inline")
Pointer<Float> operator -(int offset) =>
Pointer.fromAddress(address - sizeOf<Float>() * offset);
operator -() extension#
A pointer to the offsetth Bool
before this one.
Equivalent to this + (-offset).
Returns a pointer to the Bool
whose address is
offset times the size of Bool
before the address of this pointer.
That is, (this - offset).address == this.address - offset * sizeOf<Bool>().
Also, (this - offset).value is equivalent to this[-offset],
and similarly for setting,
Available on Pointer<T extends NativeType>, provided by the BoolPointer extension
Implementation
@Since('3.3')
@pragma("vm:prefer-inline")
Pointer<Bool> operator -(int offset) =>
Pointer.fromAddress(address - sizeOf<Bool>() * offset);
operator -() extension#
A pointer to the offsetth Int64
before this one.
Equivalent to this + (-offset).
Returns a pointer to the Int64
whose address is
offset times the size of Int64
before the address of this pointer.
That is, (this - offset).address == this.address - offset * sizeOf<Int64>().
Also, (this - offset).value is equivalent to this[-offset],
and similarly for setting,
Available on Pointer<T extends NativeType>, provided by the Int64Pointer extension
Implementation
@Since('3.3')
@pragma("vm:prefer-inline")
Pointer<Int64> operator -(int offset) =>
Pointer.fromAddress(address - sizeOf<Int64>() * offset);
operator -() extension#
A pointer to the offsetth Pointer<T>
before this one.
Equivalent to this + (-offset).
Returns a pointer to the Pointer<T>
whose address is
offset times the size of Pointer<T> before the address of this pointer.
That is, (this - offset).address == this.address - offset * sizeOf<Pointer<T>>().
Also, (this - offset).value is equivalent to this[-offset],
and similarly for setting,
Available on Pointer<T extends NativeType>, provided by the PointerPointer<T extends NativeType> extension
Implementation
external Pointer<Pointer<T>> operator -(int offset);
operator -() extension#
A pointer to the offsetth Int8
before this one.
Equivalent to this + (-offset).
Returns a pointer to the Int8
whose address is
offset times the size of Int8
before the address of this pointer.
That is, (this - offset).address == this.address - offset * sizeOf<Int8>().
Also, (this - offset).value is equivalent to this[-offset],
and similarly for setting,
Available on Pointer<T extends NativeType>, provided by the Int8Pointer extension
Implementation
@Since('3.3')
@pragma("vm:prefer-inline")
Pointer<Int8> operator -(int offset) =>
Pointer.fromAddress(address - sizeOf<Int8>() * 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 UnionPointer<T extends Union> 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 AbiSpecificIntegerPointer<T extends AbiSpecificInteger> extension
Implementation
external Pointer<T> operator -(int offset);
operator -() extension#
A pointer to the offsetth Uint64
before this one.
Equivalent to this + (-offset).
Returns a pointer to the Uint64
whose address is
offset times the size of Uint64
before the address of this pointer.
That is, (this - offset).address == this.address - offset * sizeOf<Uint64>().
Also, (this - offset).value is equivalent to this[-offset],
and similarly for setting,
Available on Pointer<T extends NativeType>, provided by the Uint64Pointer extension
Implementation
@Since('3.3')
@pragma("vm:prefer-inline")
Pointer<Uint64> operator -(int offset) =>
Pointer.fromAddress(address - sizeOf<Uint64>() * offset);
operator -() extension#
A pointer to the offsetth Uint16
before this one.
Equivalent to this + (-offset).
Returns a pointer to the Uint16
whose address is
offset times the size of Uint16
before the address of this pointer.
That is, (this - offset).address == this.address - offset * sizeOf<Uint16>().
Also, (this - offset).value is equivalent to this[-offset],
and similarly for setting,
Available on Pointer<T extends NativeType>, provided by the Uint16Pointer extension
Implementation
@Since('3.3')
@pragma("vm:prefer-inline")
Pointer<Uint16> operator -(int offset) =>
Pointer.fromAddress(address - sizeOf<Uint16>() * offset);
operator -() extension#
A pointer to the offsetth Double
before this one.
Equivalent to this + (-offset).
Returns a pointer to the Double
whose address is
offset times the size of Double
before the address of this pointer.
That is, (this - offset).address == this.address - offset * sizeOf<Double>().
Also, (this - offset).value is equivalent to this[-offset],
and similarly for setting,
Available on Pointer<T extends NativeType>, provided by the DoublePointer extension
Implementation
@Since('3.3')
@pragma("vm:prefer-inline")
Pointer<Double> operator -(int offset) =>
Pointer.fromAddress(address - sizeOf<Double>() * offset);
operator ==() override#
Equality for Pointers only depends on their address.
Implementation
bool operator ==(Object other) {
if (other is! Pointer) return false;
Pointer otherPointer = other;
return address == otherPointer.address;
}
operator []() extension#
The float at address + sizeOf<Float>() * index.
A Dart double loses precision before being stored, and the float value is converted to a double when it is loaded.
The address must be 4-byte aligned.
Available on Pointer<T extends NativeType>, provided by the FloatPointer extension
Implementation
external double operator [](int index);
operator []() extension#
The bool at address + sizeOf<Bool>() * index.
Available on Pointer<T extends NativeType>, provided by the BoolPointer extension
Implementation
external bool operator [](int index);
operator []() extension#
The 64-bit two's complement integer at address + sizeOf<Int64>() * index.
The address must be 8-byte aligned.
Available on Pointer<T extends NativeType>, provided by the Int64Pointer extension
Implementation
external int operator [](int index);
operator []() extension#
The 16-bit two's complement integer at address + sizeOf<Int16>() * index.
A Dart integer is truncated to 16 bits (as if by .toSigned(16)) before
being stored, and the 16-bit value is sign-extended when it is loaded.
The address must be 2-byte aligned.
Available on Pointer<T extends NativeType>, provided by the Int16Pointer extension
Implementation
external int operator [](int index);
operator []() extension#
Load a Dart value from this location offset by index.
A Pointer is unboxed before being stored (as if by
.address), and the
pointer is boxed (as if by Pointer.fromAddress) when loaded.
On 32-bit platforms the address must be 4-byte aligned, and on 64-bit platforms the address must be 8-byte aligned.
Available on Pointer<T extends NativeType>, provided by the PointerPointer<T extends NativeType> extension
Implementation
external Pointer<T> operator [](int index);
operator []() extension#
The 32-bit unsigned integer at address + sizeOf<Uint32>() * index.
A Dart integer is truncated to 32 bits (as if by .toUnsigned(32)) before
being stored, and the 32-bit value is zero-extended when it is loaded.
The address must be 4-byte aligned.
Available on Pointer<T extends NativeType>, provided by the Uint32Pointer extension
Implementation
external int operator [](int index);
operator []() extension#
The double at address + sizeOf<Double>() * index.
The address must be 8-byte aligned.
Available on Pointer<T extends NativeType>, provided by the DoublePointer extension
Implementation
external double operator [](int index);
operator []() extension#
The 8-bit two's complement integer at address + sizeOf<Int8>() * index.
A Dart integer is truncated to 8 bits (as if by .toSigned(8)) before
being stored, and the 8-bit value is sign-extended when it is loaded.
Available on Pointer<T extends NativeType>, provided by the Int8Pointer extension
Implementation
external int operator [](int index);
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#
Creates a reference to access the fields of this union backed by native
memory at address + sizeOf<T>() * index.
The address must be aligned according to the union 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 UnionPointer<T extends Union> extension
Implementation
external T operator [](int index);
operator []() extension#
The 32-bit two's complement integer at address + sizeOf<Int32>() * index.
A Dart integer is truncated to 32 bits (as if by .toSigned(32)) before
being stored, and the 32-bit value is sign-extended when it is loaded.
The address must be 4-byte aligned.
Available on Pointer<T extends NativeType>, provided by the Int32Pointer extension
Implementation
external int operator [](int index);
operator []() extension#
The 8-bit unsigned integer at address + sizeOf<Uint8>() * index.
A Dart integer is truncated to 8 bits (as if by .toUnsigned(8)) before
being stored, and the 8-bit value is zero-extended when it is loaded.
Available on Pointer<T extends NativeType>, provided by the Uint8Pointer extension
Implementation
external int operator [](int index);
operator []() extension#
The integer at address + sizeOf<T>() * index.
Available on Pointer<T extends NativeType>, provided by the AbiSpecificIntegerPointer<T extends AbiSpecificInteger> extension
Implementation
external int operator [](int index);
operator []() extension#
The 64-bit unsigned integer at address + sizeOf<Uint64>() * index.
The address must be 8-byte aligned.
Available on Pointer<T extends NativeType>, provided by the Uint64Pointer extension
Implementation
external int operator [](int index);
operator []() extension#
The 16-bit unsigned integer at address + sizeOf<Uint16>() * index.
A Dart integer is truncated to 16 bits (as if by .toUnsigned(16)) before
being stored, and the 16-bit value is zero-extended when it is loaded.
The address must be 2-byte aligned.
Available on Pointer<T extends NativeType>, provided by the Uint16Pointer extension
Implementation
external int operator [](int index);
operator []=() extension#
The 16-bit unsigned integer at address + sizeOf<Uint16>() * index.
A Dart integer is truncated to 16 bits (as if by .toUnsigned(16)) before
being stored, and the 16-bit value is zero-extended when it is loaded.
The address must be 2-byte aligned.
Available on Pointer<T extends NativeType>, provided by the Uint16Pointer extension
Implementation
external void operator []=(int index, int value);
operator []=() extension#
The 8-bit unsigned integer at address + sizeOf<Uint8>() * index.
A Dart integer is truncated to 8 bits (as if by .toUnsigned(8)) before
being stored, and the 8-bit value is zero-extended when it is loaded.
Available on Pointer<T extends NativeType>, provided by the Uint8Pointer extension
Implementation
external void operator []=(int index, int value);
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);
operator []=() extension#
Store a Dart value into this location offset by index.
A Pointer is unboxed before being stored (as if by
.address), and the
pointer is boxed (as if by Pointer.fromAddress) when loaded.
On 32-bit platforms the address must be 4-byte aligned, and on 64-bit platforms the address must be 8-byte aligned.
Available on Pointer<T extends NativeType>, provided by the PointerPointer<T extends NativeType> extension
Implementation
external void operator []=(int index, Pointer<T> value);
operator []=() extension#
The 32-bit unsigned integer at address + sizeOf<Uint32>() * index.
A Dart integer is truncated to 32 bits (as if by .toUnsigned(32)) before
being stored, and the 32-bit value is zero-extended when it is loaded.
The address must be 4-byte aligned.
Available on Pointer<T extends NativeType>, provided by the Uint32Pointer extension
Implementation
external void operator []=(int index, int value);
operator []=() extension#
The integer at address + sizeOf<T>() * index.
Available on Pointer<T extends NativeType>, provided by the AbiSpecificIntegerPointer<T extends AbiSpecificInteger> extension
Implementation
external void operator []=(int index, int value);
operator []=() extension#
The double at address + sizeOf<Double>() * index.
The address must be 8-byte aligned.
Available on Pointer<T extends NativeType>, provided by the DoublePointer extension
Implementation
external void operator []=(int index, double value);
operator []=() extension#
The 32-bit two's complement integer at address + sizeOf<Int32>() * index.
A Dart integer is truncated to 32 bits (as if by .toSigned(32)) before
being stored, and the 32-bit value is sign-extended when it is loaded.
The address must be 4-byte aligned.
Available on Pointer<T extends NativeType>, provided by the Int32Pointer extension
Implementation
external void operator []=(int index, int value);
operator []=() extension#
The 64-bit unsigned integer at address + sizeOf<Uint64>() * index.
The address must be 8-byte aligned.
Available on Pointer<T extends NativeType>, provided by the Uint64Pointer extension
Implementation
external void operator []=(int index, int value);
operator []=() extension#
The float at address + sizeOf<Float>() * index.
A Dart double loses precision before being stored, and the float value is converted to a double when it is loaded.
The address must be 4-byte aligned.
Available on Pointer<T extends NativeType>, provided by the FloatPointer extension
Implementation
external void operator []=(int index, double value);
operator []=() extension#
The 16-bit two's complement integer at address + sizeOf<Int16>() * index.
A Dart integer is truncated to 16 bits (as if by .toSigned(16)) before
being stored, and the 16-bit value is sign-extended when it is loaded.
The address must be 2-byte aligned.
Available on Pointer<T extends NativeType>, provided by the Int16Pointer extension
Implementation
external void operator []=(int index, int value);
operator []=() extension#
The 8-bit two's complement integer at address + sizeOf<Int8>() * index.
A Dart integer is truncated to 8 bits (as if by .toSigned(8)) before
being stored, and the 8-bit value is sign-extended when it is loaded.
Available on Pointer<T extends NativeType>, provided by the Int8Pointer extension
Implementation
external void operator []=(int index, int value);
operator []=() extension#
Copies the value union 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 UnionPointer<T extends Union> extension
Implementation
external void operator []=(int index, T value);
operator []=() extension#
The bool at address + sizeOf<Bool>() * index.
Available on Pointer<T extends NativeType>, provided by the BoolPointer extension
Implementation
external void operator []=(int index, bool value);
operator []=() extension#
The 64-bit two's complement integer at address + sizeOf<Int64>() * index.
The address must be 8-byte aligned.
Available on Pointer<T extends NativeType>, provided by the Int64Pointer extension
Implementation
external void operator []=(int index, int value);
Static Methods#
fromFunction()#
Convert Dart function to a C function pointer, automatically marshalling the arguments and return value
If an exception is thrown while calling f(), the native function will
return exceptionalReturn, which must be assignable to return type of
f.
The returned function address can only be invoked on the mutator (main) thread of the current isolate. It will abort the process if invoked on any other thread. Use NativeCallable.listener to create callbacks that can be invoked from any thread.
The pointer returned will remain alive for the duration of the current isolate's lifetime. After the isolate it was created in is terminated, invoking it from native code will cause undefined behavior.
Pointer.fromFunction only accepts static or top level functions. Use NativeCallable.isolateLocal to create callbacks from any Dart function or closure.
Implementation
external static Pointer<NativeFunction<T>> fromFunction<T extends Function>(
@DartRepresentationOf('T') Function f, [
Object? exceptionalReturn,
]);