패키지, 저장소 및 앱 카테고리 검색

패키지 상세v0.10.10

workmanager

Flutter Workmanager. 이 플러그인을 사용하면 Android 및 iOS에서 백그라운드 작업을 예약할 수 있습니다.

AndroidiOS
30일 다운로드
35.3만
좋아요
2.4천
Pub 점수
140

패키지 설치

flutter pub add workmanager

패키지 개요

공개 정보를 바탕으로 생성한 선택 가이드입니다.

Workmanager는 Android 및 iOS 플랫폼에서 백그라운드 작업을 스케줄링할 수 있는 Flutter 플러그인입니다. 앱이 종료된 상태에서도 주기적 또는 한 번만 실행되는 작업을 수행할 수 있어 데이터 동기화, 업데이트 가져오기, 백그라운드 파일 처리와 같은 작업에 적합합니다. 네이티브 백그라운드 실행 서비스와 통합되어 시스템 제약 조건 내에서 신뢰성 있게 작업을 실행합니다. 구성 가능한 간격과 조건을 지원하는 포어그라운드 및 백그라운드 모드를 모두 지원합니다.

사용 사례

  • 스케줄된 데이터 동기화
  • 백그라운드 파일 처리
  • 주기적인 API 풀링
  • 푸시 알림 처리
  • 배터리 효율적인 작업 실행

주요 기능

  • 크로스 플랫폼 백그라운드 작업
  • 주기적 및 한 번만 실행되는 작업 지원
  • 사용자 지정 가능한 실행 간격
  • 네이티브 OS 백그라운드 서비스와의 통합
  • 낮은 배터리 및 전력 최적화

적합한 대상

  • 신뢰할 수 있는 백그라운드 실행이 필요한 앱
  • 데이터 집약형 애플리케이션
  • 오프라인 우선 애플리케이션
  • 사용자 상호작용 없이 정기적인 업데이트가 필요한 앱
  • Android 및 iOS 둘 다를 대상으로 하는 개발자

고려 사항

  • iOS는 더 엄격한 백그라운드 실행 정책으로 인해 제한됨
  • Xcode에서 백그라운드 모드를 올바르게 구성해야 합니다
  • 장치의 전력 절약 기능에 의해 제한될 수 있습니다
  • 시간 민감한 작업에 적합하지 않습니다
  • 신뢰성을 위해 실제 장치에서 테스트가 필요합니다

원본 README

연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.

Flutter Workmanager

pub package pub points likes popularity GitHub Workflow Status license

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.

📖 Documentation

Get started with background tasks in Flutter:

→ Quick Start Guide - Installation and setup

→ API Documentation - Complete Dart API reference

→ Debugging Guide - Troubleshooting help

→ 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:

await Workmanager().registerOneOffTask(
  "upload-task",
  "upload_files",
  foregroundServiceConfig: ForegroundServiceConfig(
    notificationTitle: "Uploading files",
    notificationText: "Your files are being uploaded",
  ),
);

See the Quick Start guide for details and platform caveats.

🛑 Cancelling Running Work (Android)

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')
void callbackDispatcher() {
  Workmanager().executeTask(
    (taskName, inputData) async {
      return true;
    },
    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.

🐛 Issues & Support

🚀 Example App

See the example folder for a complete working demo with all task types and platform configurations.

카테고리

의존성

의존성 목록 5 개

소스 저장소

이 패키지를 사용하는 프로젝트