WeakReference<T extends Object> class Null safety

A weak reference to a Dart object.

A weak reference to the target object which may be cleared (set to reference null instead) at any time when there is no other way for the program to access the target object.

Being the target of a weak reference does not keep an object from being garbage collected.

There are no guarantees that a weak reference will ever be cleared even if all references to its target are weak references.

Not all objects are supported as targets for weak references. The WeakReference constructor will reject any object that is not supported as an Expando key.

Annotations
  • @Since("2.17")

Constructors

WeakReference(T target)
Creates a WeakReference pointing to the given target. [...]
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
target → T?
The current object weakly referenced by this, if any. [...]
read-only

Methods

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