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

hashCode int
The hash code for this object.
no setterinherited
job Future<QueueJob?>
Returns the persisted QueueJob record for this job payload, if one already exists.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

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