Struct class
The supertype of all FFI struct types.
FFI struct types should extend this class and declare fields corresponding to the underlying native structure.
Field declarations in a Struct subclass declaration are automatically given a setter and getter implementation which accesses the native struct's field in memory.
All field declarations in a Struct subclass declaration must either have type int or float
and be annotated with a NativeType representing the native type, or must be of type Pointer. For example:
typedef struct { int a; float b; void* c; } my_struct;
class MyStruct extends Struct { @Int32 external int a; @Float external double b; external Pointer<Void> c; }
All field declarations in a Struct subclass declaration must be marked external
. You cannot create instances of the class, only have it point to existing native memory, so there is no memory in which to store non-native fields. External fields also cannot be initialized by constructors since no Dart object is being created.
Instances of a subclass of Struct have reference semantics and are backed by native memory. The may allocated via allocation or loaded from a Pointer, but cannot be created by a generative constructor.
- Inheritance
- Object
- NativeType
- Struct
- Available Extensions
Constructors
Properties
- hashCode → int read-only, inherited
- The hash code for this object. [...]
- runtimeType → Type read-only, inherited
- A representation of the runtime type of the object.
Methods
- noSuchMethod(
Invocation invocation) → dynamic inherited - Invoked when a non-existent method or property is accessed. [...]
- toString(
) → String inherited - A string representation of this object. [...]
Operators
- operator ==(
Object other) → bool inherited - The equality operator. [...]
© 2012 the Dart project authors
Licensed under the Creative Commons Attribution-ShareAlike License v4.0.
https://api.dart.dev/stable/2.13.0/dart-ffi/Struct-class.html