getPowerState static method
Gets the current power state of the device.
Includes battery level, charging state, power save mode status, and optimization recommendations.
Example:
final power = await Locus.getPowerState();
if (power.shouldRestrictTracking) {
await Locus.setTrackingProfile(TrackingProfile.offDuty);
}
Implementation
static Future<PowerState> getPowerState() async {
final result = await _methodChannel.invokeMethod('getPowerState');
if (result is Map) {
return PowerState.fromMap(Map<String, dynamic>.from(result));
}
return PowerState.unknown;
}