NativeWorkManagerClient class
Production IWorkManager that delegates to NativeWorkManager.
Use this class as the real implementation in production code. Pass FakeWorkManager in tests instead.
DI registration examples
get_it
GetIt.instance.registerLazySingleton<IWorkManager>(
() => NativeWorkManagerClient(),
);
Riverpod
final workManagerProvider = Provider<IWorkManager>(
(ref) => NativeWorkManagerClient(),
);
Flutter InheritedWidget / Provider package
Provider<IWorkManager>(
create: (_) => NativeWorkManagerClient(),
child: MyApp(),
)
- Implemented types
Constructors
- NativeWorkManagerClient()
-
const
Properties
-
events
→ Stream<
TaskEvent> -
Task completion and lifecycle events.
no setteroverride
- hashCode → int
-
The hash code for this object.
no setterinherited
-
progress
→ Stream<
TaskProgress> -
Task progress updates (downloads, uploads, chains).
no setteroverride
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
allTasks(
) → Future< List< TaskRecord> > -
Returns all task records from the persistent store.
override
-
beginWith(
TaskRequest task) → TaskChainBuilder -
Begin a task chain starting with
task.override -
cancel(
{required String taskId}) → Future< void> -
Cancel a specific task by ID.
override
-
cancelAll(
) → Future< void> -
Cancel all pending and running tasks.
override
-
cancelByTag(
{required String tag}) → Future< void> -
Cancel all tasks with the given tag.
override
-
dispose(
) → void -
No-op for the real client — NativeWorkManager is process-scoped.
override
-
enqueue(
{required String taskId, required TaskTrigger trigger, required Worker worker, Constraints constraints = const Constraints(), ExistingTaskPolicy existingPolicy = ExistingTaskPolicy.replace, String? tag}) → Future< TaskHandler> -
Schedule a single background task.
override
-
enqueueAll(
List< EnqueueRequest> requests) → Future<List< TaskHandler> > -
Schedule multiple tasks in one call.
override
-
enqueueGraph(
TaskGraph graph) → Future< GraphExecution> -
Schedule a TaskGraph (directed acyclic graph) of background tasks.
override
-
getAllTags(
) → Future< List< String> > -
Returns all active tags.
override
-
getRunningProgress(
) → Future< Map< String, TaskProgress> > -
Get the current progress of all running tasks.
override
-
getTaskRecord(
{required String taskId}) → Future< TaskRecord?> -
Returns the detailed record of a task, or
nullif not found.override -
getTasksByTag(
{required String tag}) → Future< List< String> > -
Returns all task IDs associated with
tag.override -
getTaskStatus(
{required String taskId}) → Future< TaskStatus?> -
Returns the current status of a task, or
nullif not found.override -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
pause(
{required String taskId}) → Future< void> -
Pause a running task (best-effort; effective for download workers).
override
-
resume(
{required String taskId}) → Future< void> -
Resume a previously paused task.
override
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited