Queueable mixin
Adds queue-dispatch behavior to a job-like type.
Types mixing in Queueable must implement handle and toJson. The mixin
provides:
- job hashing based on serialized payload
- queue record lookup and persistence through QueueJob
- isolate worker registration per runtime type
- async dispatch into a worker isolate
Example:
class SendWelcomeEmail with Queueable {
final String email;
SendWelcomeEmail(this.email);
@override
Map<String, dynamic> toJson() => {'email': email};
@override
Future<dynamic> handle() async {
return 'sent to $email';
}
}
final result = await SendWelcomeEmail('jane@example.com').dispatch();
Properties
Methods
-
dispatch(
) → Future - Dispatches this job for execution through a worker isolate.
-
handle(
) → Future - Executes the job payload.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toJson(
) → Map< String, dynamic> - Serializes the job payload for hashing and persistence.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited