TaskTimeout class

Task timeout configuration with soft and hard limits.

  • Soft timeout: Calls a warning callback but doesn't kill the task
  • Hard timeout: Forces task termination after the limit

Example:

final timeout = TaskTimeout(
  soft: Duration(seconds: 30),  // warn at 30s
  hard: Duration(minutes: 1),   // kill at 60s
  onSoftTimeout: (executionId) {
    print('Task taking too long: $executionId');
  },
);

await TaskFlow.enqueue('longTask', timeout: timeout);

Constructors

TaskTimeout({Duration? soft, required Duration hard, void onSoftTimeout(String executionId)?})

Properties

hard Duration
Duration before hard timeout (force kill)
final
hashCode int
The hash code for this object.
no setterinherited
onSoftTimeout → void Function(String executionId)?
Callback when soft timeout is reached
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
soft Duration?
Duration before soft timeout warning
final

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toMap() Map<String, dynamic>
Convert to map for platform channel
toString() String
A string representation of this object.
inherited

Operators

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

Static Properties

extended TaskTimeout
Preset: 30 minute hard timeout (long-running operations)
final
moderate TaskTimeout
Preset: 5 minute hard timeout (typical for background tasks)
final
quick TaskTimeout
Preset: 1 minute hard timeout (API calls, quick operations)
final

Static Methods

fromMap(Map<String, dynamic> map) TaskTimeout
Parse from map