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
-
- Object
- WithFinalizer<
K, V, SimpleFinalizerWrapper< V> > - AttachOnlyFinalizer
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
keyandvalue.override -
getWrapper(
K key) → SimpleFinalizerWrapper< V> ? -
Returns the wrapper currently associated with
key, ornullif 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
valuewithkey, 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