TaskBatch class

Batch of tasks with lifecycle callbacks.

Enqueue multiple items as a single trackable unit with then/catch/finally callbacks.

Example:

final batch = await TaskFlow.batch(
  'uploadPhotos',
  items: [photo1, photo2, photo3],
  handler: (ctx, photo) async {
    await uploadToServer(photo);
    return TaskResult.success();
  },
);

batch.then((results) {
  print('All ${results.length} photos uploaded!');
}).catch((error) {
  print('Upload failed: $error');
}).finally(() {
  print('Batch complete');
});

Constructors

TaskBatch({required String batchId, required String taskName, required int itemCount})

Properties

batchId → String
Unique batch ID
final
completedCount → int
Number of items completed
no setter
failedCount → int
Number of items failed
no setter
hashCode → int
The hash code for this object.
no setterinherited
itemCount → int
Number of items in batch
final
progress → double
Batch progress (0.0 - 1.0)
no setter
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
taskName → String
Name of the task for each item
final

Methods

catch_(void callback(Object)) → TaskBatch
Register error callback
finally_(void callback()) → TaskBatch
Register finally callback
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
then(void callback(List<Map<String, dynamic>>)) → TaskBatch
Register success callback
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited