NetworkTask<T> class
Represents a network operation task that can be executed by the RequestQueue.
Each NetworkTask encapsulates an API operation with its execution logic, completion handling, and idempotency key for safe retries.
Constructors
-
NetworkTask({required Future<
T> exec(), required String idempotencyKey, required SyncOperation operation, required String modelType, required String modelId, String? taskName}) - Creates a new NetworkTask.
Properties
-
completer
→ Completer<
T> -
Completer that will be completed when the task finishes or fails.
final
-
exec
→ Future<
T> Function() -
The execution function that performs the actual network operation.
final
-
future
→ Future<
T> -
Returns the future that completes when this task finishes.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- idempotencyKey → String
-
Unique idempotency key to prevent duplicate execution.
Format: "cuid-attempt" for retry safety.
final
- isCancelled → bool
-
Returns true if this task has been cancelled.
no setter
- modelId → String
-
The model ID being operated on.
final
- modelType → String
-
The model type being operated on.
final
- operation → SyncOperation
-
The type of sync operation this task represents.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- taskName → String?
-
Optional task name for logging purposes.
final
Methods
-
cancel(
) → void - Cancels this task with a QueueCancelledException.
-
execute(
) → Future< void> - Executes the task and completes the completer.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
Returns a string representation for logging.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited