pass property

DisposableValue<T> get pass

Returns a new instance of the same type with the same internal key value, but without any finalizer or weak reference attached to it.

The primary purpose of the pass method is to allow you to pass a DisposableValue instance to a function or another object, while ensuring that the original instance is not disposed of prematurely. The new instance returned by pass can be passed around freely, and when it is eventually disposed of, it will automatically dispose of the original instance as well.

Example:

final a = DisposableValue('hello');
final b = a.pass;
print(b.value); // Prints 'hello'
a.dispose();
print(b.value); // Throws an exception, because a was disposed

Implementation

DisposableValue<T> get pass => DisposableValue<T>._(this._key);