workmanager 플러그인을 위한 공유 플랫폼 인터페이스로, Android, iOS, Linux, macOS, Web 및 Windows에서 일관된 백그라운드 작업 실행을 가능하게 합니다. 플랫폼별 구현을 추상화하여 개발자가 신뢰할 수 있는 크로스플랫폼 코드를 작성하고, 백그라운드 작업을 안정적으로 스케줄링하고 관리할 수 있도록 합니다. 인터페이스는 호환성을 보장하고 통합된 API를 통해 네이티브 플랫폼과의 통합을 간소화합니다. 이 패키지는 workmanager 에코시스템의 기초이며 주기적 작업과 단일 작업을 지원합니다.
사용 사례
다중 플랫폼에서 백그라운드 작업 예약하기
백그라운드에서 주기적인 작업 실행
일회성 백그라운드 작업 실행
다중 플랫폼 간 일관성 보장
장시간 실행되는 백그라운드 프로세스 지원
주요 기능
다중 플랫폼 통합 API
플랫폼 추상화 계층
Android, iOS, Linux, macOS, Web 및 Windows 지원
백그라운드 작업 스케줄링을 활성화합니다
플러그인 확장성 지원
적합한 대상
백그라운드 작업을 사용하여 크로스플랫폼 앱을 개발하는 개발자
일관된 백그라운드 작업 관리가 필요한 팀
workmanager 플러그인 생태계를 사용하는 프로젝트
신뢰할 수 있는 주기적 또는 한 번만 실행되는 백그라운드 실행이 필요한 앱
고려 사항
플랫폼별 플러그인에 의해 구현되어야 합니다
구체적인 플랫폼 구현 없이는 별도로 사용할 수 없습니다
기능을 위해 메인 workmanager 패키지에 의존합니다
특정 플랫폼에서는 추가 권한이 필요할 수 있습니다
원본 README
연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.
Flutter Workmanager
Execute Dart code in the background, even when your app is closed (Android and iOS). On macOS, background tasks run while the app is running or backgrounded and the Mac is awake. Perfect for data sync, file uploads, and periodic maintenance tasks.
⚠️ Experimental web support now exists via workmanager_web (Service
Worker + Web Worker based background execution). See the
Web (experimental) page and the
package README for honest limitations and how to
test it in Chrome.
→ Troubleshooting Guide - Why tasks stop after app close (OEM battery optimization, constraints, verification)
🎯 Use Cases
Background tasks are perfect for:
Sync data from API - Keep your app's data fresh
Upload files in background - Reliable file uploads
Clean up old data - Remove old files and cache
Fetch notifications - Check for new messages
Database maintenance - Optimize and clean databases
⏱ Long-Running Tasks (Android)
For work that takes longer than the regular background execution window (bulk
uploads/downloads, ML processing), Android tasks can run as a foreground
service with a persistent notification. Pass a foregroundServiceConfig to
registerOneOffTask or registerPeriodicTask:
awaitWorkmanager().registerOneOffTask(
"upload-task",
"upload_files",
foregroundServiceConfig: ForegroundServiceConfig(
notificationTitle: "Uploading files",
notificationText: "Your files are being uploaded",
),
);
cancelByUniqueName, cancelByTag and cancelAll stop the WorkManager worker
immediately, but the Dart callback that is currently running keeps executing
unless it reacts to the stop. Pass an onTaskStopped handler to executeTask
inside your callbackDispatcher to be notified when a running task is stopped
before it finishes:
@pragma('vm:entry-point')
voidcallbackDispatcher() {
Workmanager().executeTask(
(taskName, inputData) async {
returntrue;
},
onTaskStopped: (taskName, stopReason) async {
// Mark the task as cancelled / persist state, then return promptly.
},
);
}
The handler receives the task name and the WorkManager stop reason
(cancelledByApp, timeout, preempt, ...); on Android < 12 the reason is
StopReason.unknown. Android-only — iOS has no way to stop a running task.
See the Customization guide
for details.