Disposable class abstract
Interface for objects that need cleanup when no longer used.
Classes implementing Disposable should release resources, cancel subscriptions, and perform cleanup in their dispose method.
Usage
class MyResource implements Disposable {
StreamSubscription? _subscription;
void start() {
_subscription = someStream.listen(...);
}
@override
void dispose() {
_subscription?.cancel();
_subscription = null;
}
}
Important: Always call dispose when the object is no longer needed to prevent memory leaks.
- Implementers
Constructors
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
dispose(
) → void - Releases resources held by this object.
-
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