Skip to content
pubscout

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.

WASM-readyQuiet but busy
$ flutter pub add flutter_background_service_android
Source repository

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.

Works with

Packages commonly used together with flutter_background_service_android: ones it builds on, ones built on it, and its own family.