FlutterForegroundTask class

A class that implements foreground task and provides useful utilities.

Constructors

FlutterForegroundTask()

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Properties

isIgnoringBatteryOptimizations Future<bool>
Returns whether the app has been excluded from battery optimization.
no setter
isRunningService Future<bool>
Returns whether the foreground service is running.
no setter

Static Methods

clearAllData() Future<bool>
Clears all stored data.
getData<T>({required String key}) Future<T?>
Get the stored data with key.
init({required AndroidNotificationOptions androidNotificationOptions, IOSNotificationOptions? iosNotificationOptions, ForegroundTaskOptions? foregroundTaskOptions, bool? printDevLog}) Future<void>
Initialize the FlutterForegroundTask.
minimizeApp() → void
Minimize the app to the background.
openIgnoreBatteryOptimizationSettings() Future<bool>
Open the settings page where you can set ignore battery optimization.
removeData({required String key}) Future<bool>
Remove data with key.
requestIgnoreBatteryOptimization() Future<bool>
Request to ignore battery optimization.
restartService() Future<ReceivePort?>
Restart the foreground service. The option value uses the option value of the currently running service as it is.
saveData({required String key, required Object value}) Future<bool>
Save data with key.
setTaskHandler(TaskHandler handler) → void
Set up the task handler and start the foreground task. It must always be called from a top-level function, otherwise foreground task will not work.
startService({required String notificationTitle, required String notificationText, Function? callback}) Future<ReceivePort?>
Start the foreground service with notification.
stopService() Future<bool>
Stop the foreground service.
updateService({String? notificationTitle, String? notificationText, Function? callback}) Future<bool>
Update the foreground service.
wakeUpScreen() → void
Wake up the screen of a device that is turned off.