refWithFinalizer method - StructPointer extension - dart:ffi library (original) (raw)
- @Since('3.7')
T refWithFinalizer(
- Pointer<NativeFinalizerFunction> 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 callingrefWithFinalizer.
This extension method must be invoked on a receiver of type Pointer<T>
where T
is a compile-time constant type.
Implementation
@Since('3.7')
external T refWithFinalizer(
Pointer<NativeFinalizerFunction> finalizer, {
Pointer<Void>? token,
});