fluttercommunity / fluttercommunity/flutter_workmanager

feat: WorkmanagerDebug handlers on web, linux and windows (same API as Android/iOS)

Open
#729 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Dart
Stars
1k
Forks
363
Avg merge
5h 3m
Merged PRs (30d)
6

Description

### Context

The debug-handler system (`WorkmanagerDebug.setCurrent(...)`) currently exists **only on Android (Kotlin) and iOS/macOS (Swift)**. The web, linux and windows implementations are pure Dart, so they have no equivalent — debug information on those platforms is limited to what the developer prints themselves.

The API shape (see `workmanager_android/.../WorkmanagerDebugHandler.kt`):

- `TaskDebugInfo(taskName, uniqueName, inputData, startTime)`
- `TaskResult(success, duration, error)`
- `WorkmanagerDebug` with `onTaskStatusUpdate(taskInfo, status, result)` and `onExceptionEncountered(taskInfo, exception)`
- `WorkmanagerDebug.setCurrent(handler)` / `getCurrent()`
- Built-in handlers: `LoggingDebugHandler`, `NotificationDebugHandler`

### Proposal

Add a **Dart-side mirror** of the same API in the `workmanager` package (so the call site looks identical across platforms) and emit status updates from the Dart platform implementations:

- `WorkmanagerDebug.setCurrent(...)` with the same handler contract (minus platform-specific `context`).
- `LoggingDebugHandler` (prints to console) + web-capable `NotificationDebugHandler` (browser notifications on web; no-op elsewhere).
- Wire emission:
- **web** (`workmanager_web`): task start/completion/failure in the execution path, and dispatcher exceptions.
- **linux** (`workmanager_linux`): in `BackgroundTaskRunner`.
- **windows** (`workmanager_windows`): in the Dart execution path.

### Acceptance criteria

- `WorkmanagerDebug.setCurrent(LoggingDebugHandler())` works identically on web, linux, windows (and stays a no-op-friendly default).
- Custom handlers receive `onTaskStatusUpdate` / `onExceptionEncountered` with the same `TaskDebugInfo`/`TaskStatus`/`TaskResult` semantics.
- Android/iOS keep their existing native API unchanged.

Contributor guide

Open the contributing guide

Research direction

Read the existing WorkmanagerDebugHandler.kt API, then inspect the web dispatcher execution path, linux BackgroundTaskRunner, and windows Dart execution path. Trace where tasks start, complete, fail, and report exceptions before defining the Dart-side mirror. Done means matching handlers receive the specified status and exception callbacks on web, linux, and windows while Android and iOS remain unchanged.

Written by the indexing model from the issue text.

Assessment

Tech stack
dart, flutter
Domain
api, desktop-dev, mobile-dev, web-dev
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.