lifecycle_guard_platform_interface 1.0.3
lifecycle_guard_platform_interface: ^1.0.3 copied to clipboard
Platform interface for lifecycle_guard - defines the contract for background execution.
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.
Demo #
See the lifecycle_guard ecosystem in action:

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_windowsorlifecycle_guard_webby 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:
- lifecycle_guard: The app-facing package that developers use.
- lifecycle_guard_platform_interface: (This package) The glue/contract.
- lifecycle_guard_android / ios: The actual native workers.
License #
BSD 3-Clause License — see LICENSE for details.