lifecycle_guard 1.0.1 copy "lifecycle_guard: ^1.0.1" to clipboard
lifecycle_guard: ^1.0.1 copied to clipboard

A bulletproof Flutter plugin for mission-critical background execution.

๐Ÿ›ก๏ธ lifecycle_guard #

The bulletproof Flutter plugin for mission-critical background execution.

Stop losing data when Android or iOS aggressively kills your app. lifecycle_guard ensures your background tasks survive termination, system reboots, and battery optimizations โ€” guaranteed.

GitHub pub version License: BSD-3 Flutter Platform PRs Welcome


๐ŸŽฌ Demo #

lifecycle_guard Demo

Watch lifecycle_guard in action: App swipe โ†’ Background survival โ†’ Task completion.


โœจ Features #

Feature Description
๐Ÿ›ก๏ธ Isolate Protection Boots a lightweight secondary engine so your task never shares the UI thread fate
๐Ÿค– Android 15+ Ready Fully compliant with new foregroundServiceType: dataSync requirements
๐ŸŽ iOS Compatible Bridges to Apple's native background task scheduler
๐Ÿ“ก Zero Data Loss Tasks continue even when users swipe the app away
โšก 30-Second Setup One-line API โ€” no complex native configuration needed
๐Ÿ” User-Safe No auto-execution, no hidden scripts, everything is user-triggered

๐Ÿš€ Quick Start #

Installation #

Add to your pubspec.yaml:

dependencies:
  lifecycle_guard: ^1.0.0

โš™๏ธ Platform-Specific Setup #

For production use, you must configure the native layer for each platform. Click below for detailed guides:

Platform Setup Guide Key Requirements
Android Android Guide Manifest Service, Notification Permissions
iOS iOS Guide Background Modes, Task Identifiers
Common Interface Docs Internal Contract Details

๐Ÿ’ก Usage #

import 'package:lifecycle_guard/lifecycle_guard.dart';

// Trigger a mission-critical background task
await LifecycleGuard.runSecureTask(
  id: "sync_user_data",
  payload: {
    "userId": "12345",
    "retry": true,
    "timestamp": DateTime.now().toIso8601String(),
  },
);

๐Ÿง  How It Works #

graph TD
    subgraph Flutter_Layer ["Flutter App (UI Thread)"]
        A[LifecycleGuard.runSecureTask]
    end

    subgraph Native_Bridge ["MethodChannel Bridge"]
        B{Platform Check}
    end

    subgraph Native_Layer ["Native Protection Layer"]
        C[Android: LifecycleService<br/><i>Foreground + dataSync</i>]
        D[iOS: BGTaskScheduler<br/><i>BGProcessingTask</i>]
    end

    A --> B
    B -- Android --> C
    B -- iOS --> D

    subgraph Results ["Survival Benefits"]
        E[โœ… App Swipe Survival]
        F[โœ… Doze Mode Protection]
        G[โœ… Battery Saver Compliance]
    end

    C --> Results
    D --> Results

    style Flutter_Layer fill:#02569B,color:#fff,stroke:#fff
    style Native_Layer fill:#2E7D32,color:#fff,stroke:#fff
    style Native_Bridge fill:#333,color:#fff
    style Results fill:#1b1f23,color:#3fb950,stroke:#3fb950

๐Ÿ“„ License #

BSD 3-Clause License โ€” see LICENSE for details.


Built with โค๏ธ by Crealify ยท Open to collaborate ยท PRs welcome

6
likes
0
points
141
downloads

Publisher

unverified uploader

Weekly Downloads

A bulletproof Flutter plugin for mission-critical background execution.

Homepage
Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter, lifecycle_guard_android, lifecycle_guard_ios, lifecycle_guard_platform_interface

More

Packages that depend on lifecycle_guard

Packages that implement lifecycle_guard