FlutterForegroundTask class
A class that implements foreground task and provides useful utilities.
Constructors
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
-
canDrawOverlays
→ Future<
bool> -
Returns whether the "android.permission.SYSTEM_ALERT_WINDOW" permission was granted.
no setter
-
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
-
isRunningService
→ Future<
bool> -
Returns whether the foreground service is running.
no setter
-
receivePort
→ Future<
ReceivePort?> -
Get the
ReceivePort
.no setter
Static Methods
-
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.
-
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.
-
openIgnoreBatteryOptimizationSettings(
) → Future< bool> - Open the settings page where you can set ignore battery optimization.
-
openSystemAlertWindowSettings(
{bool forceOpen = false}) → Future< bool> -
Open the settings page where you can allow/deny the "android.permission.SYSTEM_ALERT_WINDOW" permission.
pass the
forceOpen
bool to open the permissions page even if granted. -
removeData(
{required String key}) → Future< bool> -
Remove data with
key
. -
requestIgnoreBatteryOptimization(
) → Future< bool> - Request to ignore battery optimization.
-
restartService(
) → Future< bool> - Restart the foreground service.
-
saveData(
{required String key, required Object value}) → Future< bool> -
Save data with
key
. -
setOnLockScreenVisibility(
bool isVisible) → void - Toggles lockScreen visibility
-
setTaskHandler(
TaskHandler handler) → void - Set up the task handler and start the foreground task.
-
startService(
{required String notificationTitle, required String notificationText, Function? callback}) → Future< bool> - 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.