getBatteryLevel method
Gets the current battery level as a percentage (0–100).
iOS returns a packed value (percentage in upper byte), while Android returns the percentage directly. This method normalizes both.
Implementation
Future<int> getBatteryLevel() async {
final int raw = (await _get(CapturePropertyIds.batteryLevelDevice)) as int;
if (raw > 0xFF) {
return (raw >> 8) & 0xFF;
}
return raw;
}