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

androidNotificationOptions AndroidNotificationOptions?
getter/setter pair
canDrawOverlays Future<bool>
Returns whether the "android.permission.SYSTEM_ALERT_WINDOW" permission is granted.
no setter
canScheduleExactAlarms Future<bool>
Returns whether the "android.permission.SCHEDULE_EXACT_ALARM" permission is granted.
no setter
dataCallbacks List<DataCallback>
final
foregroundTaskOptions ForegroundTaskOptions?
getter/setter pair
iosNotificationOptions IOSNotificationOptions?
getter/setter pair
isAppOnForeground Future<bool>
Returns whether the app is in the foreground.
no setter
isIgnoringBatteryOptimizations Future<bool>
Returns whether the app has been excluded from battery optimization.
no setter
isInitialized bool
getter/setter pair
isRunningService Future<bool>
Returns whether the foreground service is running.
no setter
receivePort ReceivePort?
getter/setter pair
skipServiceResponseCheck bool
getter/setter pair
streamSubscription StreamSubscription?
getter/setter pair

Static Methods

addTaskDataCallback(DataCallback callback) → void
Add a callback to receive data sent from the TaskHandler.
checkNotificationPermission() Future<NotificationPermission>
Returns notification permission status.
clearAllData() Future<bool>
Clears all stored data.
getAllData() Future<Map<String, Object>>
Get all stored data.
getData<T>({required String key}) Future<T?>
Get the stored data with key.
init({required AndroidNotificationOptions androidNotificationOptions, required IOSNotificationOptions iosNotificationOptions, required ForegroundTaskOptions foregroundTaskOptions}) → void
Initialize the FlutterForegroundTask.
initCommunicationPort() → void
Initialize port for communication between TaskHandler and UI.
launchApp([String? route]) → void
Launch the app at route if it is not running otherwise open it.
minimizeApp() → void
Minimize the app to the background.
openAlarmsAndRemindersSettings() Future<bool>
Open the alarms & reminders settings page.
openIgnoreBatteryOptimizationSettings() Future<bool>
Open the settings page where you can set ignore battery optimization.
openSystemAlertWindowSettings() Future<bool>
Open the settings page where you can allow/deny the "android.permission.SYSTEM_ALERT_WINDOW" permission.
removeData({required String key}) Future<bool>
Remove data with key.
removeTaskDataCallback(DataCallback callback) → void
Remove a callback to receive data sent from the TaskHandler.
requestIgnoreBatteryOptimization() Future<bool>
Request to ignore battery optimization.
requestNotificationPermission() Future<NotificationPermission>
Request notification permission.
resetStatic() → void
Resets class's static values to allow for testing of service flow.
restartService() Future<ServiceRequestResult>
Restart the foreground service.
saveData({required String key, required Object value}) Future<bool>
Save data with key.
sendDataToMain(Object data) → void
Send date to main isolate.
sendDataToTask(Object data) → void
Send data to TaskHandler.
setOnLockScreenVisibility(bool isVisible) → void
Toggles lockScreen visibility.
setTaskHandler(TaskHandler handler) → void
Set up the task handler and start the foreground task.
startService({int? serviceId, required String notificationTitle, required String notificationText, NotificationIconData? notificationIcon, List<NotificationButton>? notificationButtons, Function? callback}) Future<ServiceRequestResult>
Start the foreground service.
stopService() Future<ServiceRequestResult>
Stop the foreground service.
updateService({ForegroundTaskOptions? foregroundTaskOptions, String? notificationTitle, String? notificationText, NotificationIconData? notificationIcon, List<NotificationButton>? notificationButtons, Function? callback}) Future<ServiceRequestResult>
Update the foreground service.
wakeUpScreen() → void
Wake up the screen of a device that is turned off.