refWithFinalizer method - UnionPointer extension - dart:ffi library (original) (raw)

  1. @Since('3.7')

T refWithFinalizer(

  1. Pointer<NativeFinalizerFunction> finalizer, {
  2. Pointer<Void>? token, })

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 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,
});