BackgroundService class

Keeps data collection running while the app is in the background on Android.

Runs an Android foreground service with a persistent notification. On iOS, background execution is not supported and all calls do nothing.

A singleton, accessed as BackgroundService(). Call initialize and then enable when the app starts. SmartPhoneClientManager.configure does this when enableBackgroundMode is true. Call disable to stop it.

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
Whether background execution is currently enabled via enable.
no setter
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

disable() → Future<bool>
Disables background execution.
enable() → Future<bool>
Enables background execution.
initialize({String? notificationTitle, String? notificationText}) → Future<bool>
Initializes the background service. Must be called before enable.
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