Minimize the app to the background.
Warning It only works when the app is in the foreground.
void function() => FlutterForegroundTask.minimizeApp();
Launch the app at route
if it is not running otherwise open it.
It is also possible to pass a route to this function but the route will only be loaded if the app is not already running.
This function requires the android.permission.SYSTEM_ALERT_WINDOW
permission and
requires using the openSystemAlertWindowSettings()
function to grant the permission.
void requestPermission() async {
if (!await FlutterForegroundTask.canDrawOverlays) {
await FlutterForegroundTask.openSystemAlertWindowSettings();
}
}
void function() => FlutterForegroundTask.launchApp([route]);
Toggles lockScreen visibility.
Warning It only works when the app is in the foreground.
void function() => FlutterForegroundTask.setOnLockScreenVisibility(true);
Returns whether the app is in the foreground.
Future<bool> function() => FlutterForegroundTask.isAppOnForeground;
Wake up the screen of a device that is turned off.
void function() => FlutterForegroundTask.wakeUpScreen();
Returns whether the app has been excluded from battery optimization.
Future<bool> function() => FlutterForegroundTask.isIgnoringBatteryOptimizations;
Open the settings page where you can set ignore battery optimization.
Warning It only works when the app is in the foreground.
Future<bool> function() => FlutterForegroundTask.openIgnoreBatteryOptimizationSettings();
Request to ignore battery optimization.
This function requires the android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS
permission.
Warning It only works when the app is in the foreground.
Future<bool> function() => FlutterForegroundTask.requestIgnoreBatteryOptimization();
Returns whether the android.permission.SYSTEM_ALERT_WINDOW
permission is granted.
Future<bool> function() => FlutterForegroundTask.canDrawOverlays;
Open the settings page where you can allow/deny the android.permission.SYSTEM_ALERT_WINDOW
permission.
Warning It only works when the app is in the foreground.
Future<bool> function() => FlutterForegroundTask.openSystemAlertWindowSettings();
Returns notification permission status.
Warning It only works when the app is in the foreground.
Future<NotificationPermission> function() => FlutterForegroundTask.checkNotificationPermission();
Request notification permission.
Warning It only works when the app is in the foreground.
Future<NotificationPermission> function() => FlutterForegroundTask.requestNotificationPermission();
Returns whether the android.permission.SCHEDULE_EXACT_ALARM
permission is granted.
Future<bool> function() => FlutterForegroundTask.canScheduleExactAlarms;
Open the alarms & reminders settings page.
Use this utility only if you provide services that require long-term survival, such as exact alarm service, healthcare service, or Bluetooth communication.
This utility requires the android.permission.SCHEDULE_EXACT_ALARM
permission.
Using this permission may make app distribution difficult due to Google policy.
Warning It only works when the app is in the foreground.
Future<bool> function() => FlutterForegroundTask.openAlarmsAndRemindersSettings();