パッケージ、リポジトリ、アプリカテゴリを検索

パッケージ詳細v0.10.5

workmanager_platform_interface

Workmanagerプラグイン用の共通プラットフォームインターフェース。

AndroidiOSLinuxmacOSWebWindows
30日間ダウンロード
28.1万
いいね数
0
Pub ポイント
150

パッケージをインストール

flutter pub add workmanager_platform_interface

パッケージ概要

公開情報に基づく選定ガイドです。参考としてご利用ください。

workmanager プラグイン用の共有プラットフォームインターフェースであり、Android、iOS、Linux、macOS、Web、Windows で一貫したバックグラウンドタスクの実行を可能にします。プラットフォーム固有の実装を抽象化し、開発者が信頼できるクロスプラットフォームコードを書くことで、バックグラウンド作業をスケジュールおよび管理できます。このインターフェースは互換性を保証し、統合されたAPIを通じてネイティブプラットフォームとの統合を簡素化します。このパッケージは、workmanagerエコシステムの基盤であり、定期タスクやワンタイムジョブなどの機能をサポートしています。

用途

  • 複数のプラットフォームでバックグラウンドタスクをスケジュールする
  • バックグラウンドで定期的なジョブを実行する
  • 一時的なバックグラウンド操作の実行
  • クロスプラットフォームの一貫性を確保する
  • 長時間実行されるバックグラウンドプロセスのサポート

主な機能

  • プラットフォーム間での統合 API
  • プラットフォーム抽象レイヤー
  • Android、iOS、Linux、macOS、Web、Windows のサポート
  • バックグラウンドタスクのスケジューリングを有効にします
  • プラグインの拡張性を促進する

適している対象

  • バックグラウンドタスクを使用してクロスプラットフォームアプリを開発する開発者
  • 一貫したバックグラウンドジョブ管理を必要とするチーム
  • workmanager プラグインエコシステムを使用するプロジェクト
  • 信頼できる定期的または一回限りのバックグラウンド実行を必要とするアプリ

注意事項

  • プラットフォーム固有のプラグインによる実装が必要です
  • 具体的なプラットフォーム実装がなければ、単独では使用できない
  • 機能の実装にはメインの workmanager パッケージに依存しています
  • 特定のプラットフォームでは追加の権限が必要になる場合があります

元の 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.

カテゴリー

依存関係

依存関係一覧 2 件

  • meta^1.10.0
  • plugin_platform_interface^2.1.0

ソースリポジトリ

このパッケージを使用しているプロジェクト

データはまだありません。

ランキング