SerializableQueueJob class abstract
Base class for serializable jobs that provides common patterns
This is an alternative to using the mixin if you prefer inheritance.
Example:
class ProcessPaymentJob extends SerializableQueueJob {
final String orderId;
final double amount;
ProcessPaymentJob(this.orderId, this.amount);
factory ProcessPaymentJob.fromJson(Map<String, dynamic> json) {
return ProcessPaymentJob(
json['orderId'] as String,
json['amount'] as double,
);
}
@override
Map<String, dynamic> toJson() => {
'orderId': orderId,
'amount': amount,
};
@override
Future<void> handle() async {
await PaymentService.process(orderId, amount);
}
}
- Inheritance
- Available extensions
Constructors
Properties
- displayName → String
-
Optional: Job display name for logging/debugging.
Defaults to the class name.
no setterinherited
- hashCode → int
-
The hash code for this object.
no setterinherited
- maxRetries → int
-
Optional: Number of times to retry this job on failure.
Default is 3 attempts.
no setterinherited
- priority → JobPriority
-
Available on QueueJob, provided by the PriorityQueueJob extension
Get job priority (default: normal)no setter - queue → String
-
Optional: Queue name to dispatch this job to.
Default is 'default'.
no setterinherited
- retryDelay → Duration
-
Optional: Delay between retry attempts.
Default is 30 seconds.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- shouldRetry → bool
-
Optional: Whether this job should be retried on failure.
Default is true.
no setterinherited
- timeout → Duration?
-
Optional: Job timeout. Job will be killed if it takes longer.
Default is no timeout.
no setterinherited
Methods
-
handle(
) → Future< void> -
Called when the job is executed.
Put your job logic here.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toJson(
) → Map< String, dynamic> -
Convert job to JSON for serialization
override
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited