flutter_foreground_task
11.0.3, released 2 months ago by pravera.me
Implement and manage foreground services on Android and iOS platforms.
What it does
This plugin allows you to run long-running repetitive tasks in a foreground service with continuous notification support. It provides two-way communication between the background task handler and the main UI isolate, along with automatic restart capabilities.
AI-written summary of version 11.0.3, based on the package's README and metadata. Report an inaccuracy
Use it when
- You need to execute repetitive background tasks that shouldn't be killed immediately when the app is minimized
- You want to display an ongoing notification for a persistent service on Android and iOS
Skip it when
- You only need simple short-lived asynchronous background tasks
- You want a fully cross-platform solution without platform-specific manifest or Info.plist configuration
Strengths
- Supports two-way communication between the background task and the main UI
- Provides options to automatically resume the foreground service on boot or package update
- Includes utilities for handling battery optimizations and notifications
Weaknesses
- Requires manual configuration of platform-specific permissions, Gradle files, and Android Manifest services
- iOS background execution is heavily limited by the operating system
Setup
- Kind
- Plugin (native code)
- Effort
- High
- Code generation
- No
- Direct dependencies
- 3
Requires modifying AndroidManifest.xml with specific foreground service types and permissions, setting up Gradle and Kotlin versions, configuring Info.plist on iOS, and setting the plugin registrant callback in AppDelegate.
void main() {
FlutterForegroundTask.initCommunicationPort();
runApp(const ExampleApp());
}Alternatives
Packages that do the same job and could replace flutter_foreground_task.
- flutter_background
Runs a Flutter app in the background on Android using a foreground service.
69Compare - android_alarm_manager_plus
Access Android AlarmManager service and run Dart code in the background.
89Compare - google_api_availability
Check the availability of Google Play services on an Android device.
88Compare - flutter_ble_peripheral
Set a device into BLE peripheral mode and advertise custom services.
86Compare
Works with
Packages commonly used together with flutter_foreground_task: ones it builds on, ones built on it, and its own family.
- platformflutter_foreground_task depends on itCross‑platform abstraction for querying runtime platform info in Dart.
- plugin_platform_interfaceflutter_foreground_task depends on itReusable base class for platform interfaces of Flutter federated plugins.
- shared_preferencesflutter_foreground_task depends on itFlutter plugin for reading and writing simple key-value pairs. Wraps NSUserDefaults on iOS and SharedPreferences on Android.
- flutter_screen_recordingBuilt on flutter_foreground_taskRecord device screen on Android, iOS, and web with optional audio.