Skip to content
pubscout

flutter_background_service

5.1.0, released 2 years ago by maseka.dev

A Flutter plugin for executing continuous Dart code even when the application is closed.

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

What it does

Executes background tasks in a separate isolate on Android and iOS. Allows persistent execution through foreground services on Android and background fetch on iOS. Facilitates communication between the UI and background service via message invocation and streams.

AI-written summary of version 5.1.0, based on the package's README and metadata. Report an inaccuracy

Use it when

  • You need to continuously sync data with a server or run a socket connection in the background.
  • You need to run timed background tasks even after the app is closed.

Skip it when

  • You only need local or push notification delivery.
  • You expect instant and continuous high-frequency execution on iOS without restrictions.

Strengths

  • Enables continuous background Dart execution on Android and iOS.
  • Provides a simple event/stream communication bridge between UI and background isolates.

Weaknesses

  • iOS background execution is heavily restricted by the OS (periodic background fetch only, lasting 15-30 seconds).
  • Requires platform-specific setup, permissions, and handling of OS battery optimizations.

Setup

Kind
Plugin (native code)
Effort
High
Code generation
No
Direct dependencies
3

Requires modifying AndroidManifest.xml, gradle configurations, and iOS Info.plist or AppDelegate.swift. Must handle foreground service permissions and battery optimization settings.

import 'package:flutter_background_service/flutter_background_service.dart';

Future<void> initializeService() async {
  final service = FlutterBackgroundService();
  await service.configure(
    androidConfiguration: AndroidConfiguration(
      onStart: onStart,
      autoStart: true,
      isForegroundMode: true,
    ),
    iosConfiguration: IosConfiguration(
      autoStart: true,
      onForeground: onStart,
    ),
  );
}

Works with

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