flutter_background_service_android
6.3.1, released a year ago by maseka.dev
Android plugin to run Dart code continuously even when the app is closed.
What it does
Provides the Android side of the flutter_background_service federated plugin. It lets a Flutter app start a foreground service that keeps executing Dart code after the UI is gone, with fixes for recent Android versions and permission handling.
AI-written summary of version 6.3.1, based on the package's README and metadata. Report an inaccuracy
Use it when
- you need to run periodic or long‑running Dart code on Android even when the app is in the background or terminated
- you require a simple foreground service without writing native Android code
Skip it when
- you need iOS support (this package is Android‑only)
- you prefer battery‑optimized scheduling like WorkManager or AlarmManager
- you need fine‑grained control over service lifecycle beyond what the plugin offers
Strengths
- easy integration via endorsed federated plugin
- handles recent Android version quirks (AGP 8.0+, Android 12/14)
- provides a straightforward API to start/stop a foreground service
Weaknesses
- Android‑only, no iOS fallback
- limited documentation beyond basic usage
- potential battery impact if misused
Setup
- Kind
- Plugin (native code)
- Effort
- Medium
- Code generation
- No
- Direct dependencies
- 1
Add FOREGROUND_SERVICE permission (and optionally POST_NOTIFICATIONS for Android 13) to AndroidManifest, configure the service declaration, and handle alarm/notification permissions on Android 12+ as described in the changelog.
import 'package:flutter_background_service/flutter_background_service.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await FlutterBackgroundService().configure(
androidConfiguration: AndroidConfiguration(
onStart: onStart,
autoStart: true,
foregroundMode: true,
),
);
runApp(MyApp());
}
void onStart() {
// Dart code that runs in the background
}
Alternatives
Packages that do the same job and could replace flutter_background_service_android.
- dart_scope_functions
Kotlin-inspired scope functions like also, let, takeIf, and run for executing code blocks on objects.
74Compare - http_status_code
A Dart library providing constants and helpers for HTTP status codes.
39Compare
Works with
Packages commonly used together with flutter_background_service_android: ones it builds on, ones built on it, and its own family.
- flutter_background_service_platform_interfaceflutter_background_service_android depends on itPlatform interface for flutter_background_service plugin
- flutter_background_service_iosSame familyRuns Dart code continuously on iOS even when the app is closed.
- flutter_background_serviceBuilt on flutter_background_service_androidA Flutter plugin for executing continuous Dart code even when the application is closed.