AttachOnlyFinalizer<K extends Object, V extends Object> class

A write-only WithFinalizer implementation.

Associates values with keys solely for finalization purposes. This class does not store, expose, or allow removal of key–value associations.

When a key becomes unreachable and is garbage-collected, the provided onFinalize callback is invoked with the associated value.

Any attempt to retrieve or manually remove an association results in UnsupportedError.

Inheritance

Constructors

AttachOnlyFinalizer(FinalizerCallback<V> onFinalize, {bool debug = false})
Creates an attach-only finalizer.

Properties

debug bool
Enables debug mode.
final
hashCode int
The hash code for this object.
no setterinherited
onFinalize FinalizerCallback<V>
User-provided callback invoked when a key is garbage-collected.
finalinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

createWrapper(K key, V value) SimpleFinalizerWrapper<V>
Creates a wrapper for the given key and value.
override
getWrapper(K key) SimpleFinalizerWrapper<V>?
Returns the wrapper currently associated with key, or null if no association exists.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
onFinalizeError(Object error, StackTrace stackTrace) → void
Called when onFinalize throws.
inherited
put(K key, V value) → void
Associates value with key, replacing any existing association.
inherited
remove(K key) → Never
Removes the association for key, if present.
override
toString() String
A string representation of this object.
inherited

Operators

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