DisposableToken class
The token part of a disposable resource management pattern, used by the resource consumer.
A DisposableToken represents a single-use resource or operation. The consumer
can cancel it, and the provider can finish or dispose it. This provides a
clear and safe way to manage the lifecycle of asynchronous operations or temporary resources.
- Implemented types
- Available extensions
Constructors
- DisposableToken.client({dynamic parent, VoidCallback? onCancel, VoidCallback? onFinish, VoidCallback? onDispose, dynamic data})
-
Creates a standalone token without a separate
DisposableClient.factory
Properties
- data ↔ dynamic
-
Additional data of this token.
getter/setter pair
- hashCode → int
-
The hash code for this object.
no setterinherited
- isActive → bool
-
Checks if cancel or dispose hasn't been executed.
no setter
- isFinished → bool
-
Checks if finish has been executed.
no setter
- onCancel ↔ VoidCallback?
-
Callback when token is canceled and
finishcalled.getter/setter pairinherited - onDispose ↔ VoidCallback?
-
Callback when token is disposed and
finishcalled.getter/setter pairinherited - onFinish ↔ VoidCallback?
-
Callback when token is finished and
finishcalled.getter/setter pairinherited - parent → dynamic
-
Parent of this disposer.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
cancel(
[bool autoDispose = true]) → void -
Cancels this token and notifies
onCancellistener. Typically called by Client. -
dispose(
) → void - Releases resources used by the object.
-
disposeWith(
DisposeObserver observer) → void -
Available on Disposable, provided by the DisposableExt extension
Register for dispose with givenobserver. -
finish(
[bool autoDispose = true]) → void -
Finishes this token and notifies
onFinishlistener. Typically called by API. -
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