BackgroundService class

A service for managing background execution on Android.

On Android, this service can be used to run data collection in the background while the app is not in the foreground. On iOS, background execution is not supported, and this service will do nothing.

Works as a singleton service, and should be initialized and enabled when the app starts, and disabled when the app is closed.

Note that the background service must be enabled in the app's manifest file. You must specify the appropriate foregroundServiceType for your use case. See the Android docs and the list of available service types for more information on foreground service types.

Uses the flutter_background package.

Constructors

BackgroundService()
Get the singleton BackgroundService.
factory

Properties

hashCode int
The hash code for this object.
no setterinherited
isEnabled bool
Has the background service been enabled?
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

disable() Future<bool>
Disable the background service.
enable() Future<bool>
Enable the background service.
initialize({String? notificationTitle, String? notificationText}) Future<bool>
Initialize the background service.
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