flutter_foreground_plugin
0.8.0, released 6 years ago by an unverified publisher
A foreground service plugin for Flutter supporting Android.
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.
- flutter_foreground_task
Implement and manage foreground services on Android and iOS platforms.
89Compare - flutter_accessibility_service
Flutter plugin to interact with Android Accessibility Service for events and actions.
71Compare - proximity_sensor
Flutter plugin to read proximity sensor events on Android and iOS
70Compare - flutter_background
Runs a Flutter app in the background on Android using a foreground service.
69Compare