NativeFinalizer class Null safety

A native finalizer which can be attached to Dart objects.

When attached to a Dart object, this finalizer's native callback is called after the Dart object is garbage collected or becomes inaccessible for other reasons.

Callbacks will happen as early as possible, when the object becomes inaccessible to the program, and may happen at any moment during execution of the program. At the latest, when an isolate group shuts down, this callback is guaranteed to be called for each object in that isolate group that the finalizer is still attached to.

Compared to the Finalizer from dart:core, which makes no promises to ever call an attached callback, this native finalizer promises that all attached finalizers are definitely called at least once before the program ends, and the callbacks are called as soon as possible after an object is recognized as inaccessible.

Constructors

NativeFinalizer(Pointer<NativeFinalizerFunction> callback)
Creates a finalizer with the given finalization callback. [...]
factory

Properties

hashCode int
The hash code for this object. [...]
read-only, inherited
runtimeType Type
A representation of the runtime type of the object.
read-only, inherited

Methods

attach(Finalizable value, Pointer<Void> token, {Object? detach, int? externalSize}) → void
Attaches this finalizer to value. [...]
detach(Object detach) → void
Detaches this finalizer from values attached with detach. [...]
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed. [...]
inherited
toString() String
A string representation of this object. [...]
inherited

Operators

operator ==(Object other) bool
The equality operator. [...]
inherited