lifecycle_guard_platform_interface 1.0.3 copy "lifecycle_guard_platform_interface: ^1.0.3" to clipboard
lifecycle_guard_platform_interface: ^1.0.3 copied to clipboard

Platform interface for lifecycle_guard - defines the contract for background execution.

lifecycle_guard Logo

lifecycle_guard_platform_interface #

The common interface contract for mission-critical background execution.

This package defines the standardized API that ensures lifecycle_guard works identically across Android, iOS, and future platforms.

GitHub pub version Flutter


Demo #

See the lifecycle_guard ecosystem in action:

Lifecycle Guard Demo


The Backbone of the Guard #

This is a Platform Interface package as defined by the Federated Plugins architecture. It serves as the single source of truth for the plugin's API, ensuring that whether you are on Android or iOS, the behavior remains consistent.

Why this package exists: #

  • Uniformity: Every platform-specific guard (Android, iOS) is forced to implement the exact same methods.
  • Safety: Prevents runtime errors by providing a static fallback implementation.
  • Community Driven: Allows anyone to build a lifecycle_guard_windows or lifecycle_guard_web by simply extending this class.

Usage for Platform Implementers #

If you are building a new platform implementation for lifecycle_guard, you must extend the LifecycleGuardPlatform class.

Example Implementation Structure: #

import 'package:lifecycle_guard_platform_interface/lifecycle_guard_platform_interface.dart';

class MyNewPlatformGuard extends LifecycleGuardPlatform {
  /// Register this implementation as the default for the current platform
  static void registerWith() {
    LifecycleGuardPlatform.instance = MyNewPlatformGuard();
  }

  @override
  Future<void> runSecureTask({
    required String id,
    Map<String, dynamic>? payload,
  }) async {
    // Your platform-specific native logic goes here
    // e.g., Start a Windows Service or a Web Worker
    print("Starting secure task $id on the new platform...");
  }
}

Architecture Overview #

The platform interface acts as the middleman in the federated structure:

  1. lifecycle_guard: The app-facing package that developers use.
  2. lifecycle_guard_platform_interface: (This package) The glue/contract.
  3. lifecycle_guard_android / ios: The actual native workers.

License #

BSD 3-Clause License — see LICENSE for details.


Built by [Crealify](https://anil-bhattarai.com.np)
5
likes
150
points
156
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

Platform interface for lifecycle_guard - defines the contract for background execution.

Homepage
Repository (GitHub)
View/report issues

License

BSD-3-Clause (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on lifecycle_guard_platform_interface