PowerState class

Current power state of the device.

Used to make intelligent decisions about tracking behavior based on battery level, charging state, and power save mode.

Constructors

PowerState({required int batteryLevel, required bool isCharging, ChargingType chargingType = ChargingType.none, bool isPowerSaveMode = false, bool isDozeMode = false, bool isBatteryOptimizationExempt = false, Duration? timeToFullCharge, Duration? timeRemaining})
Creates a power state.
const
PowerState.fromMap(JsonMap map)
Creates from a map.
factory

Properties

batteryLevel int
Current battery level (0-100).
final
chargingType ChargingType
Type of charging connection.
final
hashCode int
The hash code for this object.
no setterinherited
isBatteryOptimizationExempt bool
Whether app is exempt from battery optimizations.
final
isCharging bool
Whether the device is currently charging.
final
isCriticalBattery bool
Whether battery is critical (below 10%).
no setter
isDozeMode bool
Whether the device is in Doze mode (Android).
final
isLowBattery bool
Whether battery is low (below 20%).
no setter
isPowerSaveMode bool
Whether the device is in power save / low power mode.
final
optimizationSuggestion PowerOptimizationSuggestion
Suggested optimization level based on power state.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
shouldRestrictTracking bool
Whether tracking should be restricted due to power state.
no setter
timeRemaining Duration?
Estimated battery time remaining (if discharging).
final
timeToFullCharge Duration?
Estimated time to full charge (if charging).
final

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

unknown → const PowerState
Default state when power info is unavailable.