TaskMiddleware class abstract
Signature for middleware that wraps task execution.
Middleware runs before and after every task handler. Use for logging, auth token refresh, analytics, error tracking.
Example:
class LoggingMiddleware extends TaskMiddleware {
@override
Future<TaskResult> execute(
String taskName,
TaskContext ctx,
Future<TaskResult> Function() next,
) async {
print('📋 Task started: $taskName');
try {
final result = await next();
print('✅ Task completed: $taskName');
return result;
} catch (e) {
print('❌ Task failed: $taskName - $e');
rethrow;
}
}
}
// Register
TaskFlow.use(LoggingMiddleware());
Constructors
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
execute(
String taskName, TaskContext ctx, Future< TaskResult> next()) → Future<TaskResult> - Executes middleware around task handler.
-
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