EnqueueRequest class
A single task request for use with NativeWorkManager.enqueueAll.
Bundles all parameters needed to call NativeWorkManager.enqueue so that
multiple tasks can be submitted in a single NativeWorkManager.enqueueAll
call.
Example
final paths = ['/data/a.zip', '/data/b.zip'];
final urls = ['https://cdn.example.com/a.zip',
'https://cdn.example.com/b.zip'];
final results = await NativeWorkManager.enqueueAll([
for (var i = 0; i < paths.length; i++)
EnqueueRequest(
taskId: 'dl-$i',
trigger: TaskTrigger.oneTime(),
worker: NativeWorker.httpDownload(url: urls[i], savePath: paths[i]),
tag: 'batch-download',
),
]);
final accepted = results.where((r) => r == ScheduleResult.accepted).length;
print('$accepted / ${results.length} tasks accepted');
- Annotations
Constructors
- EnqueueRequest({required String taskId, required TaskTrigger trigger, required Worker worker, Constraints constraints = const Constraints(), ExistingTaskPolicy existingPolicy = ExistingTaskPolicy.replace, String? tag})
-
const
Properties
- constraints → Constraints
-
Device constraints (network, battery, etc.).
final
- existingPolicy → ExistingTaskPolicy
-
What to do when a task with taskId already exists.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- tag → String?
-
Optional tag for grouping (see NativeWorkManager.cancelByTag).
final
- taskId → String
-
Unique identifier for this task.
final
- trigger → TaskTrigger
-
When to run the task.
final
- worker → Worker
-
The worker implementation to execute.
final
Methods
-
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