BatteryService class abstract
Service interface for battery management and optimization.
Monitors battery state and provides adaptive tracking capabilities to balance location accuracy with power consumption.
Example:
// Get battery stats
final stats = await Locus.battery.getStats();
print('Battery: ${stats.level}%, Charging: ${stats.isCharging}');
// Estimate battery runway
final runway = await Locus.battery.estimateRunway();
print('Tracking time remaining: ${runway.formattedDuration}');
// Set adaptive tracking
await Locus.battery.setAdaptiveTracking(
AdaptiveTrackingConfig.aggressive,
);
// Listen to power state changes
Locus.battery.powerStateEvents.listen((event) {
if (event.powerState.isPowerSaveMode) {
print('Power save mode activated');
}
});
- Implementers
Constructors
Properties
- adaptiveTrackingConfig → AdaptiveTrackingConfig?
-
Gets the current adaptive tracking configuration.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
-
powerSaveChanges
→ Stream<
bool> -
Stream of power save mode changes.
no setter
-
powerStateEvents
→ Stream<
PowerStateChangeEvent> -
Stream of power state changes.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
calculateAdaptiveSettings(
) → Future< AdaptiveSettings> - Calculates optimal settings based on current conditions.
-
estimateRunway(
) → Future< BatteryRunway> - Estimates remaining battery runway for location tracking.
-
getPowerState(
) → Future< PowerState> - Gets current power state.
-
getStats(
) → Future< BatteryStats> - Gets current battery statistics.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
onPowerSaveChange(
void callback(bool), {Function? onError}) → StreamSubscription< bool> - Subscribes to power save mode changes.
-
onPowerStateChange(
void callback(PowerStateChangeEvent event), {Function? onError}) → StreamSubscription< PowerStateChangeEvent> - Subscribes to power state change events.
-
recordBenchmarkLocationUpdate(
{double? accuracy}) → void - Records a location update for benchmarking.
-
recordBenchmarkSync(
) → void - Records a sync event for benchmarking.
-
setAdaptiveTracking(
AdaptiveTrackingConfig config) → Future< void> - Sets adaptive tracking configuration.
-
startBenchmark(
) → Future< void> - Starts a battery benchmark test.
-
stopBenchmark(
) → Future< BenchmarkResult?> - Stops the battery benchmark and returns results.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited