PodFinalizerWrapper<T extends Object> class
final
Auto-disposes its wrapped PodNotifier when the wrapper itself becomes unreachable.
Usage: hold the wrapper, NOT the pod directly. The pod is reachable for as long as the wrapper is reachable; once the wrapper is collected, the finalizer fires and disposes the pod, then the pod itself becomes collectible.
Caveats:
- The pod IS pinned alive by the finalizer token until the wrapper is collected. This is intentional — without it the pod could be collected while still in use elsewhere and the finalizer would have nothing to dispose.
- Finalizers are best-effort. Dart makes no guarantee about when (or whether) a finalizer fires. Do NOT rely on this for resources that absolutely must be released (use explicit PodNotifier.dispose for those).
- If you also hold a strong reference to the pod elsewhere, the pod stays alive via that other reference, the wrapper can be collected independently (which detaches the finalizer), and nothing disposes the pod automatically.
Constructors
-
PodFinalizerWrapper(PodNotifier<
T> pod)
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
-
pod
→ WeakReference<
PodNotifier< T> > -
The wrapped pod, kept as a WeakReference so the wrapper does not pin
it beyond what the finalizer token does.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
detach(
) → void - Detach from the finalizer so the pod will NOT be auto-disposed when the wrapper is GC'd. Use this to transfer ownership back to a caller that will dispose manually.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited