Skip to content
pubscout

flutter_foreground_plugin

0.8.0, released 6 years ago by an unverified publisher

A foreground service plugin for Flutter supporting Android.

WASM-ready
$ flutter pub add flutter_foreground_plugin
Source repository

What it does

Allows Flutter applications to run a foreground service on Android with customizable intervals and callbacks. Supports updating notification title and contents.

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

Use it when

  • You need to run long-running tasks in a foreground service on Android
  • You need periodic callback execution within a foreground service

Skip it when

  • You need iOS support
  • You need to change the notification level

Strengths

  • Supports null safety for Flutter 2.0+
  • Provides start and stop callbacks

Weaknesses

  • Does not support iOS yet
  • Cannot change notification level

Setup

Kind
Plugin (native code)
Effort
Medium
Code generation
No
Direct dependencies
0

Requires adding the FOREGROUND_SERVICE permission, declaring the service in AndroidManifest.xml, setting the min SDK, and providing notification icons.

void main() {
  runApp(MyApp());
  startForegroundService();
}

void startForegroundService() async {
  await FlutterForegroundPlugin.setServiceMethodInterval(seconds: 5);
  await FlutterForegroundPlugin.setServiceMethod(globalForegroundService);
  await FlutterForegroundPlugin.startForegroundService(
    holdWakeLock: false,
    title: "Flutter Foreground Service",
    content: "This is Content",
    iconName: "ic_stat_hot_tub",
  );
}

void globalForegroundService() {
  debugPrint("current datetime is ${DateTime.now()}");
}

Alternatives

Packages that do the same job and could replace flutter_foreground_plugin.