BackgroundLocator class
Main class for managing background location tracking.
BackgroundLocator provides a static interface to control background location tracking on both Android and iOS platforms. It allows you to:
- Initialize the location tracking service
- Register and unregister location update callbacks
- Check if location tracking is active
- Update notification text on Android
Example usage:
// Initialize the service
await BackgroundLocator.initialize();
// Register location updates
await BackgroundLocator.registerLocationUpdate(
(LocationDto location) {
print('Location: ${location.latitude}, ${location.longitude}');
},
androidSettings: AndroidSettings(),
iosSettings: IOSSettings(),
);
// Check if tracking is running
bool isRunning = await BackgroundLocator.isServiceRunning();
// Unregister when done
await BackgroundLocator.unRegisterLocationUpdate();
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 Methods
-
initialize(
) → Future< void> - Initializes the background location tracking service.
-
isRegisterLocationUpdate(
) → Future< bool> - Checks if a location update callback is currently registered.
-
isServiceRunning(
) → Future< bool> - Checks if the background location tracking service is currently running.
-
registerLocationUpdate(
void callback(LocationDto), {void initCallback(Map< String, dynamic> )?, Map<String, dynamic> initDataCallback = const {}, void disposeCallback()?, bool autoStop = false, AndroidSettings androidSettings = const AndroidSettings(), IOSSettings iosSettings = const IOSSettings()}) → Future<void> - Registers a callback to receive location updates in the background.
-
unRegisterLocationUpdate(
) → Future< void> - Unregisters the location update callback and stops background tracking.
-
updateNotificationText(
{String? title, String? msg, String? bigMsg}) → Future< void> - Updates the notification text displayed while tracking in the background on Android.