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

패키지 상세v0.2.0

workmanager_web

백그라운드 작업 실행을 위해 Service Worker와 Web Worker를 사용한 작업 관리자의 실험적 웹 구현.

Web
30일 다운로드
19.3만
좋아요
1
Pub 점수
140

패키지 설치

flutter pub add workmanager_web

패키지 개요

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

workmanager_web는 workmanager 패키지에 대한 실험적인 웹 구현을 제공하여 서비스 워커와 웹 워커를 사용하여 Flutter 웹 앱에서 백그라운드 작업을 실행할 수 있게 해줍니다. 앱이 활성적으로 사용 중이 아닐 때도 작업을 스케줄링하고 실행할 수 있으며, 네이티브 백그라운드 처리 기능을 모방합니다. 이 패키지는 전통적인 백그라운드 실행이 제한된 웹 환경에서 주기적 및 단일 작업을 지원하도록 설계되었습니다.

사용 사례

  • 정기적인 데이터 동기화 스케줄링
  • 앱 종료 후 백그라운드 작업 실행
  • 푸시 알림 처리 구현
  • UI를 차단하지 않고 긴 실행 시간 작업을 수행하는 것
  • 오프라인 우선 애플리케이션 지원

주요 기능

  • 서비스 워커 통합
  • 웹 워커 기반 작업 실행
  • 주기적 및 단일 작업 스케줄링
  • 실험적 웹 호환성
  • 최소의 런타임 오버헤드

적합한 대상

  • 백그라운드 작업이 필요한 플러터 웹 개발자
  • 예약된 유지보수를 필요로 하는 앱
  • 오프라인 사용이 가능한 웹 애플리케이션
  • 개발자가 웹에서 백그라운드 워크플로를 테스트하는 중

고려 사항

  • 실험적 상태이며, 불안정할 수 있음
  • 서비스 워커에 대한 브라우저 지원 제한
  • 모든 브라우저에서 실행 시간이 보장되지 않습니다
  • 생산 환경에서 HTTPS가 필요합니다
  • 중요한 시간 민감한 작업에 적합하지 않습니다

원본 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.

카테고리

의존성

의존성 목록 1 개

소스 저장소

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

아직 데이터가 없습니다.

순위