BatteryRunway class

Result of battery runway estimation.

Provides predictions for how long tracking can continue at current and alternative power consumption rates.

Example:

final runway = await Locus.estimateBatteryRunway();
print('At current rate: ${runway.duration.inHours}h ${runway.duration.inMinutes % 60}m');
print('In low power mode: ${runway.lowPowerDuration.inHours}h');
print('Recommendation: ${runway.recommendation}');

Constructors

BatteryRunway({required Duration duration, required Duration lowPowerDuration, required String recommendation, required int currentLevel, bool isCharging = false, double? drainRatePerHour, double? lowPowerDrainRatePerHour, double confidence = 0.0})
Creates a battery runway estimation.
const
BatteryRunway.charging({required int currentLevel})
Creates an estimation for a charging device.
const
BatteryRunway.fromMap(JsonMap map)
Creates from a map.
factory
BatteryRunway.insufficientData({required int currentLevel, bool isCharging = false})
Creates an estimation indicating insufficient data.
const

Properties

confidence double
Confidence level of the estimation (0.0 - 1.0).
final
currentLevel int
Current battery level (0-100).
final
drainRatePerHour double?
Current drain rate in percent per hour.
final
duration Duration
Estimated remaining tracking duration at current drain rate.
final
formattedDuration String
Formatted duration string for display.
no setter
formattedLowPowerDuration String
Formatted low power duration string for display.
no setter
hashCode int
The hash code for this object.
no setterinherited
isCharging bool
Whether the device is currently charging.
final
isCritical bool
Whether the battery level is critical.
no setter
isLow bool
Whether the battery level is low but not critical.
no setter
lowPowerDrainRatePerHour double?
Low power mode drain rate in percent per hour.
final
lowPowerDuration Duration
Estimated remaining tracking duration in low power mode.
final
recommendation String
Human-readable recommendation based on current state.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
shouldSwitchToLowPower bool
Whether the estimation suggests switching to low power mode.
no setter

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toMap() JsonMap
Converts to a JSON-serializable map.
toString() String
A string representation of this object.
override

Operators

operator ==(Object other) bool
The equality operator.
inherited

Constants

criticalLevel → const int
Critical battery level threshold.
minReliableLevel → const int
Minimum battery level required for reliable tracking.